DPLSelectDocument not selecting any document
Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2844
Printed Date: 29 Sep 24 at 1:14AM Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com
Topic: DPLSelectDocument not selecting any document
Posted By: hugetto
Subject: DPLSelectDocument not selecting any document
Date 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
|
Replies:
Posted By: AndrewC
Date Posted: 05 Mar 14 at 2:45AM
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.
|
Posted By: hugetto
Date Posted: 05 Mar 14 at 7:30AM
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
|
Posted By: Ingo
Date Posted: 10 Mar 14 at 7:18PM
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
|
Posted By: hugetto
Date Posted: 11 Mar 14 at 7:47AM
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
|
Posted By: hugetto
Date Posted: 11 Mar 14 at 1:10PM
I've downloaded today the 2013 version but I still got this output.
|
Posted By: hugetto
Date Posted: 11 Mar 14 at 1:22PM
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);
|
Posted By: hugetto
Date Posted: 11 Mar 14 at 1:34PM
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.
|
Posted By: AndrewC
Date Posted: 14 Mar 14 at 1:58AM
Hugetto,
The length of the binary data returned from the library can be obtained using DPLAnsiStringResultLength(); You will need to call this directly after calling DPLRenderPageToFile.
All image will return binary data including NULL characters ('\0') and so strlen() will not work.
|
|