Logo
My Account |  Site Map | Contact Us  
Welcome Guest Search | Active Topics | Sign In | Register

Disable fetching HTML images from external servers Options
Grzegorz Brose
Posted: Tuesday, November 26, 2019 6:35:51 AM
Rank: Newbie
Groups: Member

Joined: 11/26/2019
Posts: 1
Hello,

We're using EO.PDF to convert the body of HTML emails to a PDF. Those emails may some time contain images with their "src" attribute pointing to some external servers (e.g. http://my-very-own-server.com/images/signature.png). When the conversion starts, EO.PDF attempts to download those images so they can be rendered in the PDF. However, our environment does not have internet connection so obviously there's no way for those images to be downloaded, while each attempt to do so takes very long (approximately 1 minute per each image). This drastically slows down the whole conversion and sometimes even results in a timeout exception being thrown.

How can we configure EO.PDF to prevent it from attempting to download such images?

Thank you in advance.
eo_support
Posted: Tuesday, November 26, 2019 11:33:02 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 21,737
Hi,

You can use the following code to precisely control how long you wish to wait:

Code: C#
//Use manual trigger mode
HtmlToPdfOptions options = new HtmlToPdfOptions();
options.TriggerMode = HtmlToPdfTriggerMode.Manual;

//Use a HtmlToPdfSession object to gain access to the underlying WebView object
using (HtmlToPdfSession session = HtmlToPdfSession.Create(options))
{
    session.RunWebViewCallback(() =>
    {
        //Load the Url you wish to convert
        EO.WebBrowser.NavigationTask task = session.WebView.LoadUrl(url);

        //Wait for the main page to finish loading --- note that this 
        //does NOT mean all the dependency resources such as the
        //image in question in your case has finished loading. It only 
        //means the main page has finished loading
        task.WaitOne();

        //Use a timer to trigger the conversion. You must use setTimeout to
        //to set the trigger because RenderAsPDF reset the trigger
        session.WebView.EvalScript("setTimeout(function(){eopdf.convert();}, 2000);");
    });

    //Wait until eopdf.convert() to be called and then start conversion
    session.RenderAsPDF(Pdf_file);
}


Hope this 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.