Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
DPLSelectDocument not selecting any document |
Post Reply |
Author | |
hugetto
Beginner Joined: 04 Mar 14 Status: Offline Points: 7 |
Post Options
Thanks(0)
Posted: 04 Mar 14 at 11:39AM |
Hello, I'm trying the trial version in C++ but i cannot Select any document.
This is the code I use: DEBENUPDFLIBRARYLIB1012_DllMain(GetModuleHandle(NULL), DLL_PROCESS_ATTACH, NULL); InstanceID = DPLCreateLibrary(); if (DPLUnlockKey(InstanceID, L"<insert license key here>") == 1) { int DocumentID = DPLDAOpenFileReadOnly(InstanceID, L"C:\\file.pdf", nullptr); int err = DPLLastErrorCode(InstanceID); int lSelected = DPLSelectDocument(InstanceID, DocumentID); int lOutDoc = DPLSelectedDocument(InstanceID); } This are the output variables: InstanceID = 99020448 DocumentID = 1476395009 err = 0 lSelected = 0 //which means have failed, but I don't know why it failed lOutDoc = 1476395008 //Why it's the same number as DocumentID minus 1? What's happening? Thank you Edited by AndrewC - 05 Mar 14 at 2:38AM |
|
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
|
Hello,
You are mixing DA functions with non DA functions. The DA functions only work with other DA functions. So if you change the following line from int DocumentID = DPLDAOpenFileReadOnly(InstanceID, L"C:\\file.pdf", nullptr); to int ret = DPLLoadFromFile(InstanceID, L"C:\\file.pdf", nullptr); DocumentId = DQPLSelectedDocument(InstanceID); If ret = 1 then the file has loaded correctly. The ID's are handle numbers we use internally. Andrew. |
|
hugetto
Beginner Joined: 04 Mar 14 Status: Offline Points: 7 |
Post Options
Thanks(0)
|
Thank you for this information, but i've got the same results when I render the page with the DPLRenderPageToString function
int DocumentID = DPLLoadFromFile(InstanceID, L"C:\\example.pdf", nullptr); char *ret = DPLRenderPageToString(InstanceID, 24, 1, 5); The DocumentID is 1 The *ret value is "‰PNG\r\n\x1a\n" using the DPLLoadFromFile function and the DPLDAOpenFileReadOnly function. What I'm doing wrong? Thank you |
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi,
i don't know what's wrong in your special issue. What you should check is: Is it possible to open the pdf with a good reader like Foxit? At second you should use LastErrorCode (after each function line). Perhaps this function will tell you what's going wrong. Cheers and welcome here, Ingo |
|
Cheers,
Ingo |
|
hugetto
Beginner Joined: 04 Mar 14 Status: Offline Points: 7 |
Post Options
Thanks(0)
|
Hi Ingo,
I can open my pdf with a pdf viewer. And I put err = DPLLastErrorCode(InstanceID); After every function, and always return 0. This is the function I put all together: void showpdf() { static int hug3 = 0; static int InstanceID = 0; if (hug3 == 0) { DEBENUPDFLIBRARYLIB1012_DllMain(GetModuleHandle(NULL), DLL_PROCESS_ATTACH, NULL); int err = DPLLastErrorCode(InstanceID); InstanceID = DPLCreateLibrary(); err = DPLLastErrorCode(InstanceID); if (DPLUnlockKey(InstanceID, L"your_private_licensekey") == 1) { err = DPLLastErrorCode(InstanceID); //int DocumentID = DPLDAOpenFile(InstanceID, L"C:\\Users\\Hug\\Desktop\\example.pdf", nullptr); int DocumentID = DPLLoadFromFile(InstanceID, L"C:\\Users\\Hug\\Desktop\\example.pdf", nullptr); //int m = DPLSelectDocument(InstanceID, DocumentID); err = DPLLastErrorCode(InstanceID); int lDoc = DPLSelectedDocument(InstanceID); err = DPLLastErrorCode(InstanceID); char *ret = DPLRenderPageToString(InstanceID, 24, 1, 5); err = DPLLastErrorCode(InstanceID); hug3 = true; } } } Here are the debug output variables DocumentID 1476395009 int lDoc 1476395008 int ret 0x06493688 "‰PNG\r\n\x1a\n" char * err 0 int InstanceID 105836192 int hug3 1 int Thank you Edited by hugetto - 11 Mar 14 at 1:18PM |
|
hugetto
Beginner Joined: 04 Mar 14 Status: Offline Points: 7 |
Post Options
Thanks(0)
|
I've downloaded today the 2013 version but I still got this output.
|
|
hugetto
Beginner Joined: 04 Mar 14 Status: Offline Points: 7 |
Post Options
Thanks(0)
|
I tried other functions like on the turorial, and they work propperly:
Ex: DPLDrawText(InstanceID, 100, 500, L”Hello world”); DPLSaveToFile(InstanceID, L”C:\\Docs\\HelloFromLIB.pdf”); DPLReleaseLibrary(InstanceID); |
|
hugetto
Beginner Joined: 04 Mar 14 Status: Offline Points: 7 |
Post Options
Thanks(0)
|
I can render to a png file using this function:
DPLRenderPageToFile(InstanceID, 64, 1, 5, L"C:\\Users\\Hug\\Desktop\\example.png"); But I can't using the other function. I did strlen on the char* ret and i get 8 which is the "‰PNG\r\n\x1a\n" string. I could use the render to file function, but I would prefer to use the other one if possible. |
|
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
|
Hugetto, All image will return binary data including NULL characters ('\0') and so strlen() will not work. Andrew.
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store