Print Page | Close Window

Problem with LoadFromString in 7.12 (DLL Version)

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=1059
Printed Date: 13 May 25 at 8:37AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Problem with LoadFromString in 7.12 (DLL Version)
Posted By: Jim Sullivan
Subject: Problem with LoadFromString in 7.12 (DLL Version)
Date Posted: 13 Apr 09 at 11:15AM
I'm having a problem with LoadFromString when using the DLL version of 7.12.  The old version 5 LoadFromString and SaveToString returned a string.  This was problematic because of binary data such as images.
 
The new version returns a byte array.  Which is great for me since I was converting the string to a byte array anyway.  So the following code works just fine in my ASP.NET application:
 

Dim buffer As Byte()

Dim DataToRead As Int32

Dim pr As New QuickPDFDLL0712.PDFLibrary("C:\Quick PDF Library 7.12\DLL\QuickPDFDLL0712.dll")

Dim encoding As New System.Text.ASCIIEncoding

pr.UnlockKey("mykey")

pr.SelectImage(pr.AddImageFromFile("C:\Files\Images\image.GIF", 0))

pr.DrawImage(100, 100, 20, 30)

pr.DrawText(150, 500, "With image")

buffer = pr.SaveToString

Response.Expires = 0

Response.Buffer = True

Response.ClearHeaders()

Response.ContentType = "application/pdf"

Response.Expires = -1

DataToRead = buffer.Length

Response.Flush()

Response.OutputStream.Write(buffer, 0, DataToRead)

Response.Flush()

Response.End()

 
However, the following code does not work:
 

Dim buffer As Byte()

Dim DataToRead As Int32

Dim pr As New QuickPDFDLL0712.PDFLibrary("C:\Quick PDF Library 7.12\DLL\QuickPDFDLL0712.dll")

Dim encoding As New System.Text.ASCIIEncoding

pr.UnlockKey("mykey")

pr.SelectImage(pr.AddImageFromFile("C:\Files\Images\image.GIF", 0))

pr.DrawImage(100, 100, 20, 30)

pr.DrawText(150, 500, "With image")

Dim holderbuffer As Byte()

holderbuffer = pr.SaveToString

Dim abc As New QuickPDFDLL0712.PDFLibrary("C:\Quick PDF Library 7.12\DLL\QuickPDFDLL0712.dll")

abc.UnlockKey("mykey")

MsgBox(abc.LoadFromString(holderbuffer))

abc.DrawText(200, 600, "New from string")

buffer = abc.SaveToString

Response.Expires = 0

Response.Buffer = True

Response.ClearHeaders()

Response.ContentType = "application/pdf"

Response.Expires = -1

DataToRead = buffer.Length

Response.Flush()

Response.OutputStream.Write(buffer, 0, DataToRead)

Response.Flush()

Response.End()

 
The msgbox returns a 0 for LoadFromString.  This only happens for me if I put an image in the PDF.  Without an image the function works fine.  Since I'm getting a PDF in the first case, I assume that SaveToString works fine, but it's LoadFromString that's choking on the image.



Replies:
Posted By: Rowan
Date Posted: 23 Jul 09 at 6:49AM
Hi Jim,

Are you still using the 7.12 C# wrapper? If so, then we think that's the problem. There was a bug with the 7.12 C# wrapper when loading binary data (LoadFromString, AddImageFromString, etc) which has now been fixed. If you use the 7.14 DLL and 7.14 wrapper then it should work properly.

You can download the latest version from the http://www.quickpdflibrary.com/products/quickpdf/updates.php - updates page .

You can compare the code in the QuickPDFDLL0712.cs and QuickPDFDLL0714.cs files to see the difference. In 7.14 it allocates a pinned block of memory to send the binary data to Quick PDF Library.

Does this solve the problem on your end?

Cheers,
- Rowan.



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