logo
Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
Joey  
#1 Posted : Thursday, November 10, 2011 11:09:34 AM(UTC)
Joey

Rank: Administration

Reputation:

Groups: Moderators, Administration, Member
Joined: 7/16/2009(UTC)
Posts: 30
Man
Netherlands
Location: Groesbeek

Thanks: 1 times
In some cases a loop may occure if the following code is used to create a PDF file. The exact reason for this endless loop is unknown.

Quote:
While True
thedoc.FrameRect()

If thedoc.GetInfo(TheId, "Truncated") <> "1" Then
Exit While
End If

thedoc.Page = thedoc.AddPage()
TheId = thedoc.AddImageToChain(TheId)
End While


The following code solves this problem.

Quote:
Dim theID As Integer = 0
Dim theText As String = "This PDF file is generated by WebSupergoo ABCpdf.NET on the fly"

Dim theDoc As Doc = New Doc()
theDoc.Width = 4
theDoc.FontSize = 32
theDoc.Rect.Inset(20, 20)


theDoc.FrameRect()
theID = theDoc.AddHTML(theText)
While theDoc.GetInfo(theID, "Truncated") = "1"
theDoc.Page = theDoc.AddPage()
theDoc.FrameRect()
theID = theDoc.AddHTML("", theID)
End While

theDoc.Save(Server.MapPath("textflow.pdf"))
theDoc.Clear()
response.write ("PDF file written<br>")
response.write ("<a href=""textflow.pdf"">View PDF File</a>")

Wanna join the discussion?! Login to your Sienn Forum forum account. New Registrations are disabled.

bart  
#2 Posted : Monday, March 12, 2012 2:10:39 PM(UTC)
bart

Rank: Administration

Reputation:

Groups: Administration
Joined: 10/8/2008(UTC)
Posts: 188
Man

Was thanked: 1 time(s) in 1 post(s)
With this solution, sometimes you end up with empty pages
Iy you use in this case also "AddImageToChain" it might works better
Code:

    While brutpdf.GetInfo(brutID, "Truncated") = "1"
      brutpdf.Page = brutpdf.AddPage()
      brutID = brutpdf.AddImageToChain(brutID)
    End While


edit: The TheDoc.FrameRect() In Joey's example will create a border around the rect, The websupergoo examples also use this, but It's easyer to not use it.

Edited by user Wednesday, March 21, 2012 2:15:57 PM(UTC)  | Reason: Not specified

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.