Print Page | Close Window

loadFromString results in 401 error

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=2907
Printed Date: 29 Sep 24 at 12:30AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: loadFromString results in 401 error
Posted By: MrPopup
Subject: loadFromString results in 401 error
Date Posted: 27 May 14 at 11:04PM
Good morning,

Using DLL version 10.  Have tried both DPLLoadFromString and DPLLOadFromStringA. Same problem.  Jade development environment is being used.  This is the obny call I have had an issue with.

The code is:

vars
qp : PDF;
st : String;
begin
create qp transient; //create and unlock library
qp.loadFromFile("c:\temp\seka.pdf",""); //import existing pdf (4pages)
qp.deletePages(2,qp.pageCount-1); //delete all pages except page 1
qp.selectPage(1); //select page 1
st := qp.saveToString; //get pdf as a string and hold
write st.length; //check length of string
write st; //display string
delete qp; //delete and release library
create qp transient; //create and unlock library
qp.loadFromString(st,""); //load pdf from held string
write qp.lastErrorCode; //display error code
qp.saveToFile("c:\temp\test_save.pdf"); //save new document as a pdf
delete qp; //delete and release library
end;

All calls are successful except the loadFromString call.

Thank you.



Replies:
Posted By: Ingo
Date Posted: 28 May 14 at 8:27AM
is it okay with another dll-version?
If not: Please upload the pdf anywhere
and post the link - so we can check it.
 
Cheers, Ingo
 


-------------
Cheers,
Ingo



Posted By: MrPopup
Date Posted: 29 May 14 at 8:50PM
ftp site
219.89.207.2
US: quickpdf
PW pdf1004

Thank you.



Posted By: Ingo
Date Posted: 29 May 14 at 9:24PM
I think the problem is before the LoadFromString.
You should check each returning value.
What about the returning value of DeletePages?
It should be the number of the remaining pages.
I don't know Jade... the string content should be Ansi...



-------------
Cheers,
Ingo



Posted By: MrPopup
Date Posted: 29 May 14 at 9:47PM
QuickPDF Library Responses
DPLLoadFromFileA response: 1
DPLPageCount response: 4
DPLDeletePages response: 1
DPLPageCount response: 1
DPLSelectPage response: 1
String length: 219
LoadFronStringA response: 0
LastErrorCode response: 401
SaveToFile response: 1


Posted By: MrPopup
Date Posted: 29 May 14 at 10:17PM
I note that the DPLLoadFromStringA construct makes use of both char (ansi) and w_char (unicode) data types.  
No other constructs that I have used mix the two types.
Thanks.


Posted By: AndrewC
Date Posted: 30 May 14 at 10:13AM
MrPopup,

Here is the C# wrapper code for LoadFromString and SaveToString ?  It should be helpful with porting it to Jade.  The C# wrapper is calling the DLL also.

Andrew.

        public int LoadFromString(byte[] Source, string Password)
        {
            if (dll == null) return 0;
            else
            {
                GCHandle gch = GCHandle.Alloc(Source, GCHandleType.Pinned);
                IntPtr bufferID = dll.DebenuPDFLibraryCreateBuffer(instanceID, Source.Length);
                dll.DebenuPDFLibraryAddToBuffer(instanceID, bufferID, gch.AddrOfPinnedObject(), Source.Length);
                int result = dll.DebenuPDFLibraryLoadFromString(instanceID, bufferID, Password);
                dll.DebenuPDFLibraryReleaseBuffer(instanceID, bufferID);
                gch.Free();
                return result;
            }
        }

        public byte[] SaveToString()
        {
            if (dll == null) return new byte[0];
            else
            {
                IntPtr data = dll.DebenuPDFLibrarySaveToString(instanceID);
                int size = dll.DebenuPDFLibraryAnsiStringResultLength(instanceID);
                byte[] result = new byte[size];
                Marshal.Copy(data, result, 0, size);
                return result;
            }
        }



Posted By: MrPopup
Date Posted: 31 May 14 at 9:45PM
Thank you Andrew. I am not sure how I would use this, but appreciate the effort.


Posted By: AndrewC
Date Posted: 04 Jun 14 at 7:14AM

Mr Popup,

You will need do some research and see how strings and arrays work in Jade.  The code examples show how the C# wrapper loads and saves strings using the DLL calls.

Andrew.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk