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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - DPLSelectDocument not selecting any document
  FAQ FAQ  Forum Search   Register Register  Login Login

DPLSelectDocument not selecting any document

 Post Reply Post Reply
Author
Message
hugetto View Drop Down
Beginner
Beginner


Joined: 04 Mar 14
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote hugetto Quote  Post ReplyReply Direct Link To This Post Topic: DPLSelectDocument not selecting any document
    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
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post 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.


Back to Top
hugetto View Drop Down
Beginner
Beginner


Joined: 04 Mar 14
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote hugetto Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
hugetto View Drop Down
Beginner
Beginner


Joined: 04 Mar 14
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote hugetto Quote  Post ReplyReply Direct Link To This Post 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


Edited by hugetto - 11 Mar 14 at 1:18PM
Back to Top
hugetto View Drop Down
Beginner
Beginner


Joined: 04 Mar 14
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote hugetto Quote  Post ReplyReply Direct Link To This Post Posted: 11 Mar 14 at 1:10PM
I've downloaded today the 2013 version but I still got this output.
Back to Top
hugetto View Drop Down
Beginner
Beginner


Joined: 04 Mar 14
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote hugetto Quote  Post ReplyReply Direct Link To This Post 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);
Back to Top
hugetto View Drop Down
Beginner
Beginner


Joined: 04 Mar 14
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote hugetto Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post 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.

Andrew.


Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store