|
Rank: Newbie Groups: Member
Joined: 8/25/2014 Posts: 5
|
Hi, I'm getting an exception when trying to convert a few html files (after splitting them from a single html file) to pdf, And I get this exception: "Convertion failed. The operation has timed out".
I saw in some old posts this property "HtmlToPdf.Options.MaxWaitTime", but it doesn't exist anymore, So i'm out of ideas.
Why & when exactly does this exception happen? How can i resolved this issue?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, MaxLoadWaitTime should be there: http://www.essentialobjects.com/doc/4/eo.pdf.htmltopdfoptions.maxloadwaittime.aspxThe time out error usually occurs when your HTML is huge and it does take a long time to convert. If the HTML is very simple/small and you still get time out error, then you will want to check this: http://www.essentialobjects.com/doc/4/web/troubleshoot.aspxThanks!
|
|
Rank: Newbie Groups: Member
Joined: 8/25/2014 Posts: 5
|
This is my code:
Code: C#
for (int i = 0; i < _splitsCount; i++)
{
string sourceFile = GetSourceFilePath(i);
try
{
System.GC.Collect();
System.GC.Collect();
SetHtmlOptions(options); // Sets the header and footer
pdfResult = EO.Pdf.HtmlToPdf.ConvertUrl(sourceFile, new PdfDocument(), options);
results.Add(pdfResult);
}
catch (Exception ex)
{
DebugLog.Write(ex.Message);
}
}
System.GC.Collect();
System.GC.Collect();
PdfDocument finalDoc = PdfDocument.Merge(results.ToArray());
finalDoc.Save(_outputPdf);
This code converts several html files and then combine them into one pdf, and sometimes usually after converting a 2-3MB html file (which ended successfully) the next conversionof a much smaller file (300KB) is getting this exception: Quote: EO.Pdf.HtmlToPdfException: Convertion failed. The operation has timed out. ---> System.Exception: The operation has timed out. at EO.Pdf.Internal.lu.a(a A_0) at EO.Pdf.HtmlToPdfSession.a(a A_0) at EO.Pdf.Internal.l0.b(String A_0) at EO.Pdf.Internal.l0.d() --- End of inner exception stack trace --- at EO.Pdf.HtmlToPdfException.b(Exception A_0) at EO.Pdf.Internal.l0.d() at EO.Pdf.HtmlToPdfSession.RenderAsPDF(PdfDocument doc) at EO.Pdf.HtmlToPdf.ConvertUrl(String url, PdfDocument doc, HtmlToPdfOptions options) I noticed that this time out happens exactly 9 minutes after the previous successful conversion, And converting this 300KB html file alone works just fine so it's not something in the html file itself. By looking at Windows Task Manager it looks like EO.PDF is stuck on something, the memory consumption doesn't go up or down at all when converting this 300KB file (unlike in successful conversions). Any suggestions on how to fix it or why does it happen?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, Your code looks fine. Please check the troubleshooting link we posted above. If that's not the problem, please try to isolate the problem into a test project and send us the test project. We will look into it as soon as we receive that. See here for more instructions on sending test project: http://www.essentialobjects.com/forum/test_project.aspxThanks!
|
|
Rank: Newbie Groups: Member
Joined: 8/25/2014 Posts: 5
|
I have sent you a test project according to the link above.
In case you won't find a solution with my old approach, i have tried another one: I converted each single html file into a pdf file (and saved it to the HD), And then after all the html files have been converted to pdf files, i'm merging all of the pdf files into a single pdf file.
That works great (operation timeout is still being thrown here and there but much less often), but there is a new problem now - in the single merged pdf file all the links in the table of contents to other sections in the pdf doesn't work anymore, it's directing me to the browser instead.
Any idea how to solve it?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, We have posted a new build that implemented some memory optimization. Please see your private message for the download location. We have been able to run your test project successfully with the following changes: 1. Set RetrieveNodeText to false: HtmlToPdf.Options.RetrieveNodeText = false; 2. Remove all header/footer code. You can add the header/footer after the conversion. Using HeaderHtmlFormat/FooterHtmlFormat increases the conversion time signficantly. After those changes we were able to convert all file and merge them into a single PDF file. In order to merge the links, you need to call this overload: http://www.essentialobjects.com/doc/4/eo.pdf.pdfdocument.merge_overload_3.aspxNote that it takes an array of HtmlToPdfResult object instead of PdfDocument object. Please let us know if it works for you. Thanks!
|
|