\n \n \n \n \n \n \n\n\"\"\"\n\n# Instantiate Renderer\nrenderer = ChromePdfRenderer()\n\n# Enable JavaScript in our RenderingOptions\nrenderer.RenderingOptions.EnableJavaScript = True\nrenderer.RenderingOptions.WaitFor.RenderDelay(1000)\nrenderer.RenderingOptions.CssMediaType = PdfCssMediaType.Print\n\npdf = renderer.RenderHtmlAsPdf(htmlWithJs)\n\n# Export to a file or Stream\npdf.SaveAs(\"js-chart.pdf\")","about":{"@id":"https://ironpdf.com/python/examples/js-charts-to-pdf/#product"},"targetProduct":{"@id":"https://ironpdf.com/python/examples/js-charts-to-pdf/#product"},"keywords":"render charts in PDFs Python,Python render charts to PDF,IronPDF Python charts,convert graphs to PDF in Python,generate PDF from charts Python,Python PDF chart rendering tutorial","datePublished":"2023-08-23","dateModified":"2026-08-02"}]}
IRONSOFTWAREHOME
Rendering Charts in PDFs
from ironpdf import *

htmlWithJs = """
<!DOCTYPE html>
<html>
    <head>
        <meta charset='utf-8' />
        <title>C3 Bar Chart</title>
    </head>
    <body>
        <div id='chart' style='width: 950px;'></div>
        <script src='https://d3js.org/d3.v4.js'></script>
        <!-- Load c3.css -->
        <link href='https://cdnjs.cloudflare.com/ajax/libs/c3/0.5.4/c3.css' rel='stylesheet'>
        <!-- Load d3.js and c3.js -->
        <script src='https://cdnjs.cloudflare.com/ajax/libs/c3/0.5.4/c3.js'></script>
        <script>
            Function.prototype.bind = Function.prototype.bind || function (thisp) {
                var fn = this;
                return function() {
                    return fn.apply(thisp, arguments);
                };
            };
            var chart = c3.generate({
            bindto: '#chart',
            data: {
                columns: [
                    ['data1', 30, 200, 100, 400, 150, 250],
                    ['data2', 50, 20, 10, 40, 15, 25]
                ]
            }
            });
        </script>
    </body>
</html>
"""

# Instantiate Renderer
renderer = ChromePdfRenderer()

# Enable JavaScript in our RenderingOptions
renderer.RenderingOptions.EnableJavaScript = True
renderer.RenderingOptions.WaitFor.RenderDelay(1000)
renderer.RenderingOptions.CssMediaType = PdfCssMediaType.Print

pdf = renderer.RenderHtmlAsPdf(htmlWithJs)

# Export to a file or Stream
pdf.SaveAs("js-chart.pdf")
pip install ironpdf
Rendering Charts in PDFs

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.9just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

OR
bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required
Python Module Download for PDF
Install with pip

Version: 2026.9

  1. Download and install Python 3.7+.
  2. Install pip from pypi.org if it isn't installed already.
  3. Execute the above command in the terminal.
Python PDF Module
Download Module

Version: 2026.9

Manually install into your project

  1. Download the package
  2. Run this command from the terminal
    pip install ironpdf-2026.9-py37-none-win_amd64.whi

Licenses from $999