JavaScript in HTML To PDF

IronPDF for Python can render HTML that contains JavaScript, executing scripts before the PDF is captured so that dynamically generated content appears in the output.

Getting Started

Set RenderingOptions.EnableJavaScript = True on a ChromePdfRenderer instance and optionally call RenderingOptions.WaitFor.RenderDelay(ms) to give scripts enough time to finish before the page is captured. Then render your HTML string or URL as normal.

Understanding the Code

  • EnableJavaScript: When set to True, IronPDF allows <script> blocks and external scripts to execute during rendering. This is False by default for security and performance.
  • WaitFor.RenderDelay(100): Pauses for the specified number of milliseconds after the page has loaded before capturing it as a PDF. Increase this value if scripts take longer to produce their output.
  • RenderHtmlAsPdf(html): Renders the provided HTML string — including the output of any JavaScript — as a PDF document.

Dynamic Content

This feature is essential for pages that use document.write, DOM manipulation at load time, or any JavaScript-driven templating. IronPDF uses the same Chrome rendering engine as a standard web browser, so scripts that work in Chrome will behave the same way in the PDF output.

Learn to convert HTML to PDF with IronPDF for Python!

Ready to Get Started?
Version: 2026.6 just released
Still Scrolling Icon

Still Scrolling?

Want proof fast?
run a sample watch your HTML become a PDF.