Click or drag to resize

JavaScript and Page Loading

Pages built with JavaScript - charts, maps, single page applications, content loaded on demand - must finish running their scripts before the converter captures them. These properties of PdfConverter control JavaScript and decide when the page is ready. The page runs in Chromium, the engine of the Chrome browser, with the JavaScript of a current browser.

Enabling JavaScript
  • ScriptsEnabled - JavaScript runs in the converted page (true by default).

  • WebGlEnabled - WebGL for pages drawn with it (3D charts, maps). Off by default, which makes conversions faster.

Waiting for the page

The conversion starts when the page has loaded. For content that appears later, use one of these:

Property

Use

ConversionDelay

Wait a fixed number of seconds after the page loads.

WindowStatus

Wait until the page sets window.status to the given text - the page says when it is ready.

StartupMode = Manual

Wait until the page calls ExpertPdfJSObj.startConversion(). See Start conversion from JavaScript.

LazyImagesLoadingEnabled, LazyImagesLoadingDelay

Give images that load when they scroll into view the time to load.

NavigationTimeout

The maximum time to load the page (60 seconds by default).

PdfConverter converter = new PdfConverter();

// the page runs: window.status = "ready"; when its charts are drawn
converter.WindowStatus = "ready";
converter.NavigationTimeout = 120;

converter.SavePdfFromUrlToFile("https://www.example.com/dashboard", "dashboard.pdf");
Changing the page before the conversion
PdfConverter converter = new PdfConverter();
converter.CustomCSS = "#cookie-banner, nav { display: none !important; }";
converter.PostLoadingScript =
    "document.querySelectorAll('details').forEach(function (d) { d.open = true; });";
converter.SavePdfFromUrlToFile("https://www.example.com/article", "article.pdf");
See Also