Welcome Guest Search | Active Topics | Sign In | Register

HtmlToPdf.ConvertUrl sometimes creates a PDF for the PREVIOUS url Options
Ofer Sharon
Posted: Thursday, June 14, 2018 2:38:28 AM
Rank: Newbie
Groups: Member

Joined: 6/14/2018
Posts: 1
In some cases, calling HtmlToPdf.ConvertUrl produces a PDF from a wrong URL - the one sent to this method in the PREVIOUS call.
Calling again with the same URL produces the right PDF.

Here are a few lines of code that reproduce the problem:

public static void ReproduceBug_UsingPreviousUrl()
{
string url1 = "https://twitter.com/fjobh/status/989997983457595392";
string url2 = "https://twitter.com/GALIT22/status/989967125472251904";

HtmlToPdf.ConvertUrl(url1, @"C:\Temp\url1.pdf");

HtmlToPdf.ConvertUrl(url2, @"C:\Temp\url2_take1.pdf"); // Wrongly creates a PDF for url1!
HtmlToPdf.ConvertUrl(url2, @"C:\Temp\url2_take2.pdf"); // Correctly creates a PDF for url2.
}

If you run this, you can see that the files "url1.pdf" and "url2_take1.pdf" are identical.

Note: This problem only occurs for some specific URLs. For most URLs, the above code would behave correctly.

eo_support
Posted: Friday, June 15, 2018 6:25:42 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
Hi,

We have not been able to reproduce this issue with the latest build. However we did notice that twitter uses dynamic loading to load contents. This is common in modern sites as it loads an initial much simpler page and then use JavaScript to callback to the server to load additional contents. When the converter converts the page, it will start conversion as soon as the initial page is done because it has no way of knowing exactly what the JavaScript code will do next. To avoid such issue, you can add a time delay with HtmlToPdf.Options.MinLoadWaitTime property:

https://www.essentialobjects.com/doc/eo.pdf.htmltopdfoptions.minloadwaittime.aspx

You can also use manual trigger to trigger conversion. However it may not be practical in this case since you have no control of the source of the page. See here for more details about manual trigger:

https://www.essentialobjects.com/doc/pdf/htmltopdf/trigger.aspx

Hope this helps.

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.