Client-side JavaScript PDF generation for everyone.
open sourceMITself-hostablefree
jsPDF is a JavaScript library that creates PDFs in the browser (and in Node.js with a separate build) by drawing text, shapes and images through an imperative API. Its html() method can turn a DOM element into PDF content using the optional html2canvas dependency (plus DOMPurify for HTML strings). The 14 standard fonts cover only ASCII, so other scripts need a custom TTF font registered with the bundled converter or addFont. It was created by James Hall (MrRio, Parallax) and is now co-maintained by yWorks.
Problems it solves
- make a PDF in the user's browser without sending data to a server
- let users download a certificate as a PDF from a static site with no backend
- save a chart canvas or image as a PDF on the client side
- offline web app needs to produce a PDF while there's no network
- draw text, lines and boxes onto a PDF page from JavaScript
- turn a div on my page into a downloadable PDF with a button click
- add a Unicode font so Cyrillic or Chinese text shows up in a client-generated PDF
- privacy rules mean the document data can't leave the browser, but we still need a PDF
- generate a simple receipt PDF in an Angular or Vue app
Features
- imperative API for text, shapes and images
- browser builds (ES module, UMD, global) and a Node.js build
- html() via optional html2canvas and DOMPurify
- custom TTF fonts via fontconverter or addFont
- compat API mode for older plugins
- polyfills for Internet Explorer
Capabilities
| Takes plugins | plan not known |
|---|---|
| Has official SDKs | plan not known |
Alternatives
The same job
These do what jsPDF does.
- PDFKit A JavaScript PDF generation library for Node and the browser.
- pdfmake PDF document generation library for Node.js and browsers, written in pure JavaScript
- @react-pdf/renderer PDFs, made with React
- pdf-lib Create and modify PDF documents in any JavaScript environment.
- Puppeteer JavaScript API for Chrome and Firefox
- ironpress HTML to PDF. In process. In pure Rust.
