Table of contents

    Compare 10 tools to convert HTML to PDF — from open source libraries like wkhtmltopdf and Puppeteer, to Nutrient Document Engine for enterprise workflows.
    How to convert HTML to PDF: 10 best tools compared
    TL;DR

    Pick the right tool to convert HTML to PDF based on what you need to deliver:

    Secure, fillable PDFs at scaleNutrient Document Engine converts HTML to PDF with form fields, digital signatures, encryption, and workflow automation via a REST API.

    JavaScript-heavy pages to PDFPuppeteer (Chrome) or Playwright (Chromium, Firefox, WebKit) render dynamic content server-side before exporting.

    Quick browser-side exportjsPDF or html2pdf.js generate PDFs client-side with no server required.

    Python backendWeasyPrint renders HTML/CSS precisely and integrates with Django and Flask.

    PHP backendDompdf converts HTML to PDF inside Laravel, Symfony, and other PHP frameworks.

    CLI scriptingwkhtmltopdf converts HTML from the command line using WebKit.

    Programmatic PDF buildingpdfmake (JSON schema) or PDFKit (Node.js API) build PDFs from code, not markup.

    To convert an HTML file to PDF, you can use open source tools like wkhtmltopdf, Puppeteer, or jsPDF for simple jobs. For enterprise workflows requiring form conversion, digital signatures, and security, Nutrient Document Engine is the best way to convert HTML to PDF at scale.

    Common problems when you convert HTML to PDF include broken layouts, missing styles, and limited security features. This guide compares 10 tools — from browser libraries to enterprise processors — so you can pick the right one for your project.

    1. Convert HTML to PDF with Nutrient Document Engine

    Nutrient Document Engine handles HTML-to-PDF conversion for enterprise applications. This server-side toolkit handles PDF generation, editing, OCR, redaction, annotation, signing, and real-time collaboration. Run it headless as a backend service, or pair it with Nutrient’s web, mobile, or desktop SDKs.

    HTML-to-PDF conversion

    Document Engine converts HTML to PDF by accepting an HTML source (as a file or string) and processing it through a rendering engine that supports HTML5 and CSS3. It handles advanced layouts with flexbox, grid, media queries, custom fonts, and interactive elements. You send your HTML content — along with a JSON instructions object — to the /api/build endpoint. The engine returns a PDF that mirrors your original HTML, including headers, footers, watermarks, and fillable form fields.

    Example with curl:

    Terminal window
    curl -X POST http://localhost:5000/api/build \
    -H "Authorization: Token token=<API token>" \
    -F page.html=@/path/to/page.html \
    -F instructions='{ "parts": [{ "html": "page.html" }] }' \
    -o result.pdf

    This command uploads your HTML file and instructions to Document Engine, which returns the generated PDF. Because the rendering engine is Chromium-based, you can preview your HTML in Chrome to check the output before generating it.

    Key features beyond HTML-to-PDF conversion

    • Form conversion — Turn HTML forms into fillable PDFs your users can complete, sign, and submit.
    • Workflow automation — Reduce multistep processes to a single API call — merge files, add watermarks, and generate PDFs in one request.
    • Flexible deployment — Self-host on your infrastructure to meet compliance requirements, or use Nutrient’s managed cloud to ship faster.
    • Wide format support — Accept Office files, images, and HTML — deliver consistent PDFs across formats.
    • Scalable and reliable — Process large files, high-volume jobs, and concurrent requests with high availability.

    Use cases

    • Ship invoices, reports, and certificates to customers automatically — no manual PDF creation.
    • Let users fill out web forms and receive completed, signed PDFs they can download or share.
    • Add secure, compliant PDF generation to your application without building a rendering pipeline.

    Nutrient has SDKs for JavaScript, Python, Ruby, PHP, Java, and .NET. See the PDF SDK page for the full list.

    In practice, teams use open source tools for small internal scripts or low-risk exports and choose Nutrient Document Engine when HTML-to-PDF conversion is part of a production workflow (invoices, statements, contracts, reports) where layout, security, and reliability matter.

    Start a free trial or talk to Sales.

    2. Convert HTML to PDF using wkhtmltopdf

    wkhtmltopdf logo — open source CLI tool to convert HTML to PDF

    wkhtmltopdf(opens in a new tab) is a command-line tool that uses WebKit to convert HTML to PDF. It handles complex webpages with advanced CSS and JavaScript.

    Key features

    • HTML5 and CSS3 support — Converts modern webpages with HTML5 and CSS3 features.
    • Complex layout handling — Manages multicolumn designs, embedded media, and other complex layouts.
    • Customization — Offers options for page sizes, margins, headers, footers, and more.
    • JavaScript execution — Executes JavaScript before rendering, ensuring dynamic content is included.

    Limitations

    • The project is no longer actively maintained (archived since 2023).
    • Uses an older WebKit engine, so modern CSS (flexbox, grid) may not render correctly.
    • No support for fillable forms, digital signatures, or encryption.

    Use cases

    • Server-side PDF generation in web applications
    • Automated PDF creation from dynamic content
    • Print-ready documents

    Check out the following blog posts to learn more about how to use wkhtmltopdf:

    wkhtmltopdf handles basic conversion well, but it can’t produce fillable forms, apply digital signatures, or encrypt output. If you need those capabilities, Nutrient Document Engine delivers them out of the box.

    3. Convert HTML to PDF using Puppeteer

    Puppeteer logo — Node.js tool to convert HTML to PDF

    Puppeteer(opens in a new tab) is a Node.js library from Google that controls Chrome or Chromium. It renders JavaScript-heavy pages before converting them to PDF.

    Key features

    • Modern web standards support — Handles JavaScript, CSS, and HTML5, so it fully renders complex pages.
    • Dynamic content rendering — Renders single-page applications (SPAs) and other dynamic content.
    • Customizable PDF output — Controls headers, footers, and page layout in PDF output.
    • Automation integration — Integrates with automation workflows and CI/CD pipelines.

    Limitations

    • Requires a Chromium binary (~300 MB), which increases deployment size.
    • Chrome-only — no Firefox or WebKit support.
    • Cannot produce fillable forms, signatures, or encrypted PDFs.

    Example

    const puppeteer = require('puppeteer');
    (async () => {
    const browser = await puppeteer.launch();
    const page = await browser.newPage();
    await page.goto('https://example.com', {
    waitUntil: 'networkidle0',
    });
    await page.pdf({
    path: 'output.pdf',
    format: 'A4',
    printBackground: true,
    });
    await browser.close();
    })();

    Use cases

    • PDFs from JavaScript-rendered pages
    • CI/CD pipeline automation
    • Converting SPAs and interactive web apps to static PDFs

    4. Convert HTML to PDF using Playwright

    Playwright logo — cross-browser HTML-to-PDF converter

    Playwright(opens in a new tab) is a Node.js library from Microsoft that automates Chromium, Firefox, and WebKit. Unlike Puppeteer, it supports multiple browsers.

    Key features

    • Cross-browser support — Automates Chromium, Firefox, and WebKit.
    • JavaScript-heavy page handling — Renders complex, JavaScript-heavy pages.
    • PDF layout control — Supports custom page sizes and margins.
    • Integration with testing frameworks — Works with end-to-end testing frameworks for PDF generation.

    Limitations

    • Requires downloading browser binaries (~hundreds of MB per browser).
    • PDF generation only works with Chromium — Firefox and WebKit don’t support page.pdf().
    • No built-in forms, signatures, or encryption support.

    Example

    const { chromium } = require('playwright');
    (async () => {
    const browser = await chromium.launch();
    const page = await browser.newPage();
    await page.goto('https://example.com', {
    waitUntil: 'networkidle',
    });
    await page.pdf({
    path: 'output.pdf',
    format: 'A4',
    margin: { top: '1cm', bottom: '1cm' },
    });
    await browser.close();
    })();

    Use cases

    • Cross-browser PDF generation
    • Converting SPAs and complex webpages
    • Automated testing workflows with PDF output

    Check out the following blog post to learn more about how to use Playwright:

    5. Convert HTML to PDF using jsPDF

    jsPDF logo — client-side JavaScript HTML-to-PDF library

    jsPDF(opens in a new tab) is a JavaScript library for client-side PDF generation. It creates PDFs directly in the browser without a server and is best for simple layouts and static content.

    Key features

    • Basic PDF creation — Supports text, images, and shapes.
    • User interaction — Allows for annotations and other interactive features.
    • Extensible — Plugins add HTML rendering, extra fonts, and other features.
    • Basic styling — Offers basic styling through built-in methods and manual HTML parsing.
    • Customizable page orientation — Supports portrait and landscape orientation, custom page widths, and margins.

    Limitations

    • Poor support for complex CSS layouts — flexbox and grid won’t render.
    • Relies on html2canvas for HTML rendering, which rasterizes content (no selectable text in the PDF).
    • Large or multipage documents can hit browser memory limits.

    Example

    import { jsPDF } from 'jspdf';
    import html2canvas from 'html2canvas';
    const element = document.getElementById('content');
    html2canvas(element).then((canvas) => {
    const imgData = canvas.toDataURL('image/png');
    const pdf = new jsPDF('p', 'mm', 'a4');
    const width = pdf.internal.pageSize.getWidth();
    const height = (canvas.height * width) / canvas.width;
    pdf.addImage(imgData, 'PNG', 0, 0, width, height);
    pdf.save('output.pdf');
    });

    Use cases

    • Exporting HTML forms or content as PDFs
    • Simple reports generated in the browser
    • Client-side PDF generation without a server

    Check out the following blog posts to learn more about how to use jsPDF:

    6. Convert HTML to PDF using html2pdf.js

    html2pdf.js logo — browser-based HTML-to-PDF converter

    html2pdf.js(opens in a new tab) combines jsPDF and html2canvas for browser-side HTML-to-PDF conversion. It handles basic styling and images but struggles with complex layouts.

    Key features

    • HTML rendering with PDF generation — Combines HTML rendering with jsPDF’s PDF generation capabilities.
    • Image support — Supports image conversion and embedding.
    • Basic CSS styling — Allows for basic CSS styling and layouts.
    • Client-side operation — Runs entirely in the browser, which suits single-page applications (SPAs).

    Limitations

    • Rasterizes HTML via html2canvas, so text in the PDF isn’t selectable or searchable.
    • Breaks on complex CSS (grid, flexbox, sticky positioning).
    • Output quality varies across browsers and screen resolutions.

    Use cases

    • Downloadable PDFs from user-generated content
    • Exporting webpage sections
    • Lightweight browser-based PDF generation

    Check out the following blog posts to learn more about how to use html2pdf.js:

    Client-side tools like html2pdf.js work for quick exports, but the output quality depends on the browser. For consistent, production-grade PDFs with form fields and security, Nutrient Document Engine gives you server-side control over the output.

    7. Convert HTML to PDF using WeasyPrint

    WeasyPrint logo — Python HTML-to-PDF engine

    WeasyPrint(opens in a new tab) is a Python rendering engine that converts HTML and CSS to PDF. It supports modern web standards and handles complex layouts well.

    Key features

    • Modern web standards support — Supports HTML5, CSS3, and SVG.
    • Complex layouts — Accurately renders complex layouts, including multipage documents, footnotes, and page numbers.
    • Framework integration — Integrates with Django and Flask.
    • Automation — Includes a command-line interface for scripting.

    Limitations

    • No JavaScript execution — dynamic content won’t render.
    • System dependencies (Cairo, Pango) can complicate deployment.
    • Limited CSS3 support compared to browser-based tools.

    Example

    from weasyprint import HTML
    # Convert an HTML file to PDF.
    HTML('page.html').write_pdf('output.pdf')
    # Or convert a URL directly.
    HTML('https://example.com').write_pdf('output.pdf')
    # Or pass an HTML string.
    HTML(string='<h1>Hello, PDF</h1>').write_pdf('output.pdf')

    Use cases

    • Server-side PDF generation for Django and Flask apps
    • Automated report generation
    • Print-ready documents with complex layouts

    Check out the following blog post to learn more about how to use WeasyPrint:

    8. Convert HTML to PDF using pdfmake

    pdfmake logo — declarative PDF generator for Node.js and browser

    pdfmake(opens in a new tab) generates PDFs in both the browser and Node.js using a declarative JSON structure. It’s good for dynamic, programmatically generated documents.

    Key features

    • Declarative structure — Define PDF layout using a hierarchical JSON structure.
    • Rich content support — Supports text, images, tables, and vector graphics.
    • Dynamic content — Includes support for loops, conditions, and external data.
    • Customization — Provides full control over PDF structure and content.

    Limitations

    • Does not accept HTML directly — you must convert HTML to pdfmake’s JSON schema first.
    • No CSS support; all styling is done through pdfmake’s own properties.
    • Complex layouts require significant manual configuration.

    Use cases

    • Dynamic invoices, reports, and forms
    • Custom PDFs with specific layout rules
    • Works in both browser and Node.js

    Check out the following blog post to learn more about how to use pdfmake:

    9. Convert HTML to PDF using PDFKit

    PDFKit(opens in a new tab) is a Node.js library for generating PDFs programmatically. It supports text, images, vector graphics, and encryption.

    Key features

    • Advanced PDF features — Supports embedded fonts, encryption, and access controls.
    • Precise layout control — Gives fine-grained control over layout, content, and structure.
    • Streaming support — Streams large documents to avoid memory limits.
    • Node.js integration — Works with standard Node.js modules.

    Limitations

    • No HTML/CSS parsing — you build PDFs programmatically with API calls, not from markup.
    • Steep learning curve for complex layouts (manual x/y positioning).
    • No built-in digital signatures.

    Use cases

    • Server-side PDF generation
    • Complex reports, invoices, and catalogs
    • Large documents with streaming support

    Check out the following blog post to learn more about how to convert HTML to PDF with JavaScript:

    10. Convert HTML to PDF using Dompdf

    Dompdf logo — PHP library to convert HTML to PDF

    Dompdf(opens in a new tab) is a PHP library that converts HTML and CSS to PDF. It integrates with Laravel, Symfony, and other PHP frameworks.

    Key features

    • CSS2.1 and CSS3 support — Supports most CSS2.1 properties and some CSS3 properties.
    • HTML5 rendering — Renders HTML5, including inline PHP and complex tables.
    • Custom fonts and styles — Provides support for custom fonts and styles.

    Limitations

    • No JavaScript execution — only static HTML and CSS.
    • Limited CSS3 support (no flexbox or grid).
    • Slow on large or image-heavy documents.

    Use cases

    • PHP-based PDF generation
    • Converting web forms and reports to PDF
    • Automated PDF creation in Laravel/Symfony apps

    If your PHP application needs digital signatures, encryption, or fillable forms in the generated PDFs, Nutrient Document Engine provides a REST API you can call from PHP or any other language.

    Comparison: Best tools to convert HTML to PDF

    LibraryLanguageLicenseFillable formsSignaturesEncryptionJavaScript support
    wkhtmltopdfCommand lineOpen source (LGPLv3)NoNoNoYes
    PuppeteerNode.jsOpen source (Apache 2)NoNoNoYes
    PlaywrightNode.jsOpen source (Apache 2)NoNoNoYes
    jsPDFJavaScriptOpen source (MIT)NoNoNoN/A (client-side)
    html2pdf.jsJavaScriptOpen source (MIT)NoNoNoN/A (client-side)
    WeasyPrintPythonOpen source (BSD)NoNoNoNo
    pdfmakeJavaScriptOpen source (MIT)NoNoNoN/A (JSON schema)
    PDFKitNode.jsOpen source (MIT)NoNoYesN/A (programmatic)
    DompdfPHPOpen source (LGPL)NoNoNoNo
    Nutrient Document EngineREST APICommercial (free trial)YesYesYesYes

    Open source options handle one-off jobs and internal tooling well. For recurring or compliance-sensitive workflows, Nutrient Document Engine is the better fit.

    Enterprise consideration: Most open source tools can’t produce fillable forms, encrypt output, or meet compliance requirements. Nutrient Document Engine delivers all three, backed by support and SLA terms — so your team can deliver secure PDFs without maintaining the infrastructure.

    How to choose the right tool to convert HTML to PDF

    The right tool to convert HTML to PDF depends on your project requirements.

    1. Complexity of content

    If your HTML includes complex layouts or dynamic elements, frameworks like Playwright or pdfmake can help for code-level control. For pixel-perfect output on invoices, statements, and reports, Nutrient Document Engine uses Chromium-based rendering and adds forms, signatures, and encryption.

    2. Forms support

    If your users need to fill out, sign, and return PDFs, Nutrient Document Engine automatically converts HTML <input> elements into fillable PDF form fields — so your team doesn’t have to build a separate forms pipeline.

    Other tools generate static PDFs. Only Nutrient Document Engine turns HTML forms into interactive, fillable PDFs in a single API call.

    3. Performance and security

    Server-side tools handle large or confidential documents better than client-side libraries. Teams often start with open source and switch to Nutrient Document Engine when they need encrypted output, audit trails, or guaranteed uptime for customer-facing PDF workflows.

    Best practices for HTML-to-PDF conversion

    Regardless of which tool you choose, these practices help you produce reliable PDFs from HTML.

    Use print-specific CSS

    Add a @media print stylesheet to control how your HTML renders in PDF output. Remove navigation, footers, and ads; set explicit page margins; and force background colors to print:

    @media print {
    nav, footer, .no-print { display: none; }
    body { margin: 0; font-size: 12pt; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    }

    Set explicit page dimensions

    Most tools default to US Letter. If your audience expects A4, set it explicitly. In Puppeteer and Playwright, pass format: 'A4'. In CSS, use @page { size: A4; margin: 2cm; }.

    Optimize images before conversion

    Large images slow down conversion and bloat PDF file size. Compress images to web-quality resolution (150 DPI is enough for screen PDFs; use 300 DPI for print). Prefer JPEG for photos and PNG for diagrams.

    Wait for dynamic content to load

    If your page loads data asynchronously, make sure the converter waits before generating the PDF. In Puppeteer, use waitUntil: 'networkidle0'. In Playwright, use waitUntil: 'networkidle'. Skipping this step is the most common cause of blank or incomplete PDFs.

    Test with real content

    Don’t test with “Lorem ipsum” and expect production HTML to look the same. Long headings, oversized images, and multipage tables all break layouts. Test with your actual data before going to production.

    Handle page breaks

    Use page-break-before, page-break-after, and page-break-inside: avoid in CSS to prevent tables, images, and headings from splitting across pages.

    Nutrient Document Engine supports all of these practices out of the box — including print CSS, custom page sizes, and automatic page-break handling — and adds features like headers, footers, and watermarks via its instructions API.

    Conclusion

    If you need to convert HTML to PDF for side projects or simple exports, the open source tools in this list work well. When your team needs to deliver secure, fillable PDFs at scale — invoices, signable contracts, and compliant reports — Nutrient Document Engine handles it without requiring a custom pipeline. Start a free trial or talk to our Sales team.

    FAQ

    What’s the best way to convert HTML to PDF?

    For enterprise applications, Nutrient Document Engine is the strongest option to convert HTML to PDF — it includes form conversion, digital signatures, and encryption, and it scales to high-volume workloads. For simple projects, use wkhtmltopdf for server-side generation, Puppeteer for JavaScript-heavy pages, or jsPDF for basic client-side needs.

    Can I convert HTML to PDF with digital signatures and encryption?

    Most open source tools can’t. Nutrient Document Engine lets you convert HTML to PDF with encryption, digital signatures, redaction, and compliance features for business applications handling sensitive documents.

    How do I convert HTML to PDF in JavaScript?

    Use Puppeteer or Playwright for server-side Node.js, or jsPDF/html2pdf.js for client-side browser conversion. For enterprise needs, Nutrient Document Engine provides a REST API that works from any JavaScript environment.

    Can I convert HTML forms to fillable PDF forms?

    Only Nutrient Document Engine automatically converts HTML form elements into fillable PDF form fields when you convert HTML to PDF. Other tools generate static PDFs.

    What’s the best way to convert HTML to PDF in Python?

    Use WeasyPrint for open source Python HTML-to-PDF conversion. For enterprise features like forms and signatures, use Nutrient Document Engine’s REST API from Python.

    Hulya Masharipov

    Hulya Masharipov

    Technical Writer

    Hulya is a frontend web developer and technical writer who enjoys creating responsive, scalable, and maintainable web experiences. She’s passionate about open source, web accessibility, cybersecurity privacy, and blockchain.

    Explore related topics

    Try for free Ready to get started?