HTML to PDF
Client-side HTML-to-PDF rendering using pure JavaScript. Uses html2canvas + jsPDF. Converts any webpage or element into a printable PDF entirely in the browser.
Open the official app on ekoopmans.github.io
This tool is hosted by its maintainers. Click below to open ekoopmans.github.io in a new tab — it's their official demo.
Browse pdf & tools tools →What's next with HTML to PDF?
Choose how you want to get started.
Use it free
Open the official tool or demo — no account needed.
Self-host it
Run the open-source version on your own infrastructure.
What is HTML to PDF?
HTML to PDF is an open-source project licensed under the MIT license with 4,900 stars on GitHub, maintained at https://github.com/eKoopmans/html2pdf.js. The tool converts any webpage or element into a printable PDF entirely client-side. It acts as a wrapper that combines html2canvas and jsPDF into a single, cohesive solution. By leveraging these underlying libraries, html2pdf.js allows developers to take DOM elements or full web pages and generate downloadable PDF files directly. It provides flexible installation options including a cdnjs script tag, direct download of `dist/html2pdf.bundle.min.js`, and package installation via NPM using `npm install --save html2pdf.js`. Every step of the tool is configurable through a Promise-based API or an optional `opt` parameter, allowing users to define margins, filenames, image settings, html2canvas scales, and jsPDF properties such as units, formats, and orientation.
How it works
html2pdf.js is an open-source project written in JavaScript and released under the MIT license. It functions entirely client-side by depending on two core external packages: html2canvas and jsPDF. The library supports multiple integration environments, including raw JavaScript via cdnjs URLs, direct script inclusion of bundled distribution files (`dist/html2pdf.bundle.min.js`), Node-based environments via NPM (`npm install --save html2pdf.js`), and Bower. It offers two usage styles: a legacy monolithic style taking direct function arguments, and a modern Promise-based Worker API that enables method chaining, custom intermediate function injection, and automated prerequisite handling for canvas and PDF generation steps.
How to use it
- 1Include html2pdf.js in your HTML by referencing a specific version via cdnjs, downloading `dist/html2pdf.bundle.min.js` directly to your project folder, or installing it via NPM using the command `npm install --save html2pdf.js` (ensuring you include the `.js` in the package name).
- 2Select the target DOM element you want to convert to a PDF using standard JavaScript, such as `var element = document.getElementById('element-to-print');`.
- 3Define an optional configuration object `opt` to customize your PDF output, including parameters for margins, filenames, image type and quality, html2canvas scale settings, and jsPDF units, formats, and orientation.
- 4Generate the PDF and prompt the user to save it using the monolithic-style usage by calling `html2pdf(element, opt);`.
- 5Alternatively, use the new Promise-based API to chain execution steps by calling `html2pdf().set(opt).from(element).save();` or manipulate the underlying `Worker` object directly for advanced custom workflows.
What it can do
- Conversion
- Preview
Use cases
Assumptions and limitations
Assumptions
- source: https://github.com/eKoopmans/html2pdf.js
- license: MIT — free to use
- privacy: Opens an external demo
Limitations
- The rendering engine html2canvas is not entirely perfect, and if html2canvas fails to render content correctly, the limitation cannot be fixed by html2pdf.js itself.
- The node cloning mechanism used by html2pdf.js to duplicate content and CSS before sending it to html2canvas can be buggy.
- Using the unbundled version requires careful handling of dependencies as outlined in the documentation's dependency section.
Understanding the result
Client-side HTML-to-PDF rendering using pure JavaScript. Uses html2canvas + jsPDF. Converts any webpage or element into a printable PDF entirely in the browser.
Tool details
- Clearly flagged when a network request is needed.
- No account, no sign-up, and no tracking of your content.
- Powered by html2pdf.js (MIT).
- Built with
- html2pdf.js (eKoopmans/html2pdf.js)
- License
- MIT
- Runs locally
- No — requires a network request
- Verification
- Not yet verified
- Input
- Text Input
- Output
- HTML
Built with eKoopmans/html2pdf.js. OpenToolVault provides the discovery and browser interface while crediting the original project maintainers.
- Built with
- html2pdf.js
- License
- MIT
Open-source project
OpenToolVault is an independent directory. We are not affiliated with or endorsed by this project.
References
- eKoopmans/html2pdf.js — GitHub Repository
Upstream project · GitHub
- MIT License
Upstream project
Frequently asked
What underlying libraries power html2pdf.js?
html2pdf.js converts webpages or elements into printable PDFs entirely client-side using html2canvas and jsPDF.
How does the Promise-based Worker API function?
Calling html2pdf() without arguments returns a Worker object whose methods can be chained sequentially as each Promise resolves, allowing you to insert your own intermediate functions and utilize a prerequisite system to skip mandatory steps like canvas creation.
How do I install html2pdf.js using NPM?
You can install html2pdf.js and its dependencies using NPM with the command `npm install --save html2pdf.js`, making sure to include `.js` in the package name.
What configuration options are available through the opt parameter?
The opt parameter supports optional fields including margin, filename, image settings (type and quality), html2canvas options (such as scale), and jsPDF settings (such as unit, format, and orientation).
What should I do if html2canvas fails to render my content correctly?
Because html2canvas is not perfect, rendering issues may stem from the canvas creation itself. You can test this using a tool like JSFiddle to see if the problem exists in the canvas creation layer.