|
Rank: Advanced Member Groups: Member
Joined: 6/19/2013 Posts: 38
|
I am creating my html, calling HtmlToPdf.ConvertHtml and then getting the page numbers and changing the html to include the page numbers, and then calling HtmlToPdf.ConvertHtml again with the new html. But it never completes the second time, just hangs. I assume it is because I need to clear the resources from the first conversion, but I cannot find how to do that. All of the example code treats eo.pdf as a singleton so that is how I have been coding it. I have tried to instantiate another instance of eo.pdf.HtmlToPdf so I can use that, but it does not work (the new object does not have the expected properties and methods) I am obviously missing something here. How do I run multiple conversions? Here is my code:
Code: Visual Basic.NET
HTML = BuildReportHTML()
EO.Pdf.HtmlToPdf.DebugConsole = Console.Out
EO.Pdf.HtmlToPdf.Options.AutoBookmark = True
EO.Pdf.HtmlToPdf.Options.BaseUrl = WorkFolder
EO.Pdf.HtmlToPdf.Options.TriggerMode = EO.Pdf.HtmlToPdfTriggerMode.Manual
EO.Pdf.HtmlToPdf.Options.PageSize = New SizeF(8.5F, 11.0F)
EO.Pdf.HtmlToPdf.Options.OutputArea = New RectangleF(Template.Margins.Left, Template.Margins.Top, Template.Margins.Width, Template.Margins.Height)
result = EO.Pdf.HtmlToPdf.ConvertHtml(HTML, doc)
' Capture Page numbers of sites
GetPageNumbers(CType(ReportData("DETAIL"), ReportDetails), result)
GetPageNumbers(CType(ReportData("SUBJECTSITES"), ReportDetails), result)
GetPageNumbers(Template, result)
HTML = BuildReportHTML()
result = Nothing
result = EO.Pdf.HtmlToPdf.ConvertHtml(HTML, doc)
Thanks, Brad
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
Your code looks fine. Since you are using manual trigger, the first thing you want to check is whether your code indeed have called eopdf.convert(). If for some reason that code is not called, you will get time out error.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 6/19/2013 Posts: 38
|
I just figured it out. I noticed that on the second attempt I was getting javascript errors that indicated my .js libraries were not being loaded, which tell me the EO.Pdf.HtmlToPdf.Options.BaseUrl value was wrong. Sure enough, all of my HtmlToPdf.Options are getting cleared after the conversion! If I set all of the options again, the conversion works. At least EO.Pdf.HtmlToPdf.DebugConsole stayed set so I could spot the errors coming back. So this code works:
Code: Visual Basic.NET
HTML = BuildReportHTML()
EO.Pdf.HtmlToPdf.DebugConsole = Console.Out
EO.Pdf.HtmlToPdf.Options.AutoBookmark = True
EO.Pdf.HtmlToPdf.Options.BaseUrl = WorkFolder
EO.Pdf.HtmlToPdf.Options.TriggerMode = EO.Pdf.HtmlToPdfTriggerMode.Manual
EO.Pdf.HtmlToPdf.Options.PageSize = New SizeF(8.5F, 11.0F)
EO.Pdf.HtmlToPdf.Options.OutputArea = New RectangleF(Template.Margins.Left, Template.Margins.Top, Template.Margins.Width, Template.Margins.Height)
result = EO.Pdf.HtmlToPdf.ConvertHtml(HTML, doc)
' Capture Page numbers of sites and pages
GetPageNumbers(CType(ReportData("DETAIL"), ReportDetails), result)
GetPageNumbers(CType(ReportData("SUBJECTSITES"), ReportDetails), result)
GetPageNumbers(Template, result)
HTML = BuildReportHTML()
result = Nothing
doc = New PdfDocument()
EO.Pdf.HtmlToPdf.DebugConsole = Console.Out
EO.Pdf.HtmlToPdf.Options.AutoBookmark = True
EO.Pdf.HtmlToPdf.Options.BaseUrl = WorkFolder
EO.Pdf.HtmlToPdf.Options.TriggerMode = EO.Pdf.HtmlToPdfTriggerMode.Manual
EO.Pdf.HtmlToPdf.Options.PageSize = New SizeF(8.5F, 11.0F)
EO.Pdf.HtmlToPdf.Options.OutputArea = New RectangleF(Template.Margins.Left, Template.Margins.Top, Template.Margins.Width, Template.Margins.Height)
result = EO.Pdf.HtmlToPdf.ConvertHtml(HTML, doc)
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
Glad that you figured it out. That makes sense. Some HtmlToPdf.Options properties are automatically cleared after each conversion. The documentation will tell you which property is cleared after the conversion.
Thanks!
|
|