Rendering Charts in PDFs

IronPDF for Python can render interactive JavaScript chart libraries — such as D3.js and C3.js — directly to PDF, producing high-quality chart images without any additional image conversion step.

Getting Started

Build your chart in a self-contained HTML string that includes the necessary CDN script tags. Set EnableJavaScript = True and add a generous WaitFor.RenderDelay to ensure the chart library has finished drawing before the PDF is captured. Optionally set CssMediaType to Print to apply print-specific styles.

Understanding the Code

  • EnableJavaScript: Required to execute the D3 and C3 scripts that generate the chart.
  • WaitFor.RenderDelay(1000): Waits 1000 milliseconds after page load. Chart libraries perform asynchronous rendering, so a longer delay is needed compared to simple DOM manipulation.
  • CssMediaType = PdfCssMediaType.Print: Activates @media print CSS rules, which typically removes interactive controls and produces a cleaner chart layout in the PDF.
  • RenderHtmlAsPdf(htmlWithJs): Renders the complete HTML — including the rendered chart — as a PDF document.

Supported Chart Libraries

Because IronPDF uses the Chrome rendering engine, any JavaScript chart library that runs in a browser will also render correctly to PDF. This includes Chart.js, Highcharts, ApexCharts, ECharts, and others.

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.