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 > Sample Code
  New Posts New Posts RSS Feed - DPLLoadFromString Fails
  FAQ FAQ  Forum Search   Register Register  Login Login

DPLLoadFromString Fails

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


Joined: 23 Jan 13
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xan Quote  Post ReplyReply Direct Link To This Post Topic: DPLLoadFromString Fails
    Posted: 23 Jan 13 at 11:11PM
Hello,

I'm using QuickPDF Library as a LIB, building a DLL to be a browser plugin.  It works great overall.  Right now, I'm taking in a Base64-encoded PDF as input, decoding it, writing that file to a temporary file, and then loading that with DPLLoadFromFile.

It would be really nice to use DPLLoadFromString, since I have a std::string containing the Base64-decoded data, but I can't get it to work.  The call to DPLLoadFromString always returns 0.

I've tried several machinations, but here's what I believe ought to work.  Can anybody help?
DPLLoadFromString(InstanceID, const_cast<char *>(decoded_content.c_str()), L"");




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: 24 Jan 13 at 7:00AM
I see you are using C++.  The word string is a little confusing as it actually refers to a Delphi AnsiString which is a little different to a char pointer.

I suggest you read the final comment in the following thread.  It shows how to create an AnsiString buffer which can be used with LoadFromString.

http://www.quickpdf.org/forum/using-qpl8xx-with-realbasic-realstudio_topic2315.html

int BufferID , Test , ImageID;

BufferID = QPDFCreateBuffer ( InstanceID , buffer.Size )
if (BufferID != 0)  // OK
{
    Test = QPDFAddToBuffer (InstanceID , BufferID , buf, sizeof(buf));

    QPDFLoadFromFromString (InstanceID,  BufferID , "");

    Test = QPDFReleaseBuffer ( InstanceID,  BufferID )
}



Edited by AndrewC - 13 Mar 14 at 12:09AM
Back to Top
Xan View Drop Down
Beginner
Beginner


Joined: 23 Jan 13
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xan Quote  Post ReplyReply Direct Link To This Post Posted: 24 Jan 13 at 5:01PM
Thank you very much!  It now works.  Here's the C++ version, in case anybody stumbles across this.


char * buffer = DPLCreateBuffer(InstanceID, decoded_content.length());
if(buffer == 0)
{ return "Unable to create buffer"; }
DPLAddToBuffer(InstanceID, buffer, const_cast<char *>(decoded_content.c_str()), decoded_content.length());
if(DPLLoadFromString(InstanceID, buffer, L"") == 0)
{
    DPLReleaseBuffer(InstanceID, buffer);
    return "Unable to load PDF";
}
DPLReleaseBuffer(InstanceID, buffer);

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