Welcome Guest Search | Active Topics | Sign In | Register

EO.Pdf exception "Convertion failed. The operation has timed out" when trying to convert h Options
Idan
Posted: Monday, August 25, 2014 7:18:56 AM
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?
eo_support
Posted: Monday, August 25, 2014 9:49:52 AM
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.aspx

The 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.aspx

Thanks!
Idan
Posted: Tuesday, August 26, 2014 8:07:16 AM
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?
eo_support
Posted: Tuesday, August 26, 2014 9:17:36 AM
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.aspx

Thanks!
Idan
Posted: Wednesday, August 27, 2014 10:12:35 AM
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?
eo_support
Posted: Wednesday, August 27, 2014 11:07:26 PM
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.aspx

Note that it takes an array of HtmlToPdfResult object instead of PdfDocument object.

Please let us know if it works for you.

Thanks!


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.