Table of Contents
  • Getting Started
  • EO.Pdf
  • EO.Web
    • Overview
    • Installation & Deployement
    • EO.Web ToolTip
    • EO.Web Rating
    • EO.Web Slider & RangeSlider
    • EO.Web ListBox
    • EO.Web ComboBox
    • EO.Web Captcha
    • EO.Web ASPX To PDF
    • EO.Web Slide
    • EO.Web Flyout
    • EO.Web EditableLabel
    • EO.Web ImageZoom
    • EO.Web Floater
    • EO.Web Downloader
    • EO.Web ColorPicker
    • EO.Web HTML Editor
    • EO.Web File Explorer
    • EO.Web SpellChecker
    • EO.Web Grid
    • EO.Web MaskedEdit
    • EO.Web Splitter
    • EO.Web Menu
    • EO.Web Slide Menu
    • EO.Web TabStrip
    • EO.Web TreeView
    • EO.Web Calendar
    • EO.Web Callback
    • EO.Web MultiPage
    • EO.Web Dialog
    • EO.Web AJAXUploader
    • EO.Web ProgressBar - Free!
    • EO.Web ToolBar - Free!
  • EO.WebBrowser
  • EO.Wpf
  • Common Topics
  • Reference
Troubleshooting

When using ASPXToPDF or MVCToPDF to convert a page to HTML, it is very important to understand that the converter runs on your server, not on your client machine. So if a page can not be accessed directly from your web server, then ASPXToPDF or MVCToPDF may not work. This often occurs when there is a problem with DNS configuration on your server. In that case you must fix the underlying DNS configuration issues first.

For example, if page "Default.aspx" uses ASPXToPDF or MVCToPDF at Url "www.yoursite.com/Default.aspx" and the following conditions exist:

  1. When accessing "www.yoursite.com/Default.aspx" from outside with a browser, the page loads perfectly fine (as expected);
  2. When log into the web server locally, then access the same Url with a browser, the page would not load at all or would not load correctly (for example, the main page load, but underlying JavaScript, images, CSS would not load);

In this case ASPXToPDF or MVCToPDF may not work. In order for the converter work smoothly, the converter must be able to access all the page resource (JavaScript, images, CSS, etc) from within your Web Server (again, because the converter runs on your Web Server). In the above scenario, condition #2 indicates there is a problem accessing the page or resource from within your Web Server. As a result, the converter will not be able to access those resources either.

The most common cause of the above condition is a DNS configuration issue on your server. The following diagram demonstrates a typical configuration for "www.yoursite.com" with a public IP address of "1.2.3.4".

In this case, as soon as DNS entry "www.yoursite.com -> 1.2.3.4" is properly configured, Internet users would not have any problem accessing the site. However, from within your Web server, "www.yoursite.com" must resolve to "192.168.0.1" instead of "1.2.3.4". This can be easily done by manually adding a DNS entry that maps "www.yoursite.com" to "192.168.0.1" in your Web server's local host file. Without this entry, ASPXToPDF would try to connect to "1.2.3.4" to download page resources, which will fail because "1.2.3.4" is not reachable from within your Web server.

To verify whether such problem exists, log into your Web server locally, then access the same Url with a browser and see if the page loads correctly. If that does not work, then check whether DNS correctly resolves your domain name to its local IP address on the server as oppose to its public IP address.

If you are not able to change the DNS configuration, you maybe able to resolve the issue by manually setting HtmlToPdf.Options.BaseUrl value. By default, both ASPXToPDF and MVCToPDF automatically set the BaseUrl value based on the current page Url. The following steps outlines the process ASPXToPDF uses to convert the page to PDF:

  1. Capture the current page output HTML;
  2. Use the current page's base Url as HtmlToPdf.Options.BaseUrl. For example, if the current page's Url is "http://www.yoursite.com/app1/page1.apsx", then HtmlToPdf.Options.BaseUrl will be automatically set to "http://www.yoursite.com/app1/";
  3. Raises BeforeRender event. You can override the default BaseUrl value inside this event handler;
  4. Call HtmlToPdf.ConvertHtml to convert the HTML captured in step 1 to PDF;

The process MVCToPDF uses is similar except that the BeforeRender callback is not exposed as an event. In order to override BaseUrl in MVCToPDF, you must pass the event handler as an argument when calling RenderToPDF. For example:

private void ConvertToPDF()
{
    //Call RenderAsPDF with BeforeConvertHandler
    MVCToPDF.RenderAsPDF(BeforeConvertHandler, null);
}

private void BeforeConvertHandler(object sender, EventArgs e)
{
     HtmlToPdf.Options.BaseUrl = your_alternative_base_url;
}