talira

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 pluginsplan not known
Has official SDKsplan not known

Alternatives

The same job

These do what jsPDF does.

  1. PDFKit A JavaScript PDF generation library for Node and the browser.
  2. pdfmake PDF document generation library for Node.js and browsers, written in pure JavaScript
  3. @react-pdf/renderer PDFs, made with React
  4. pdf-lib Create and modify PDF documents in any JavaScript environment.
  5. Puppeteer JavaScript API for Chrome and Firefox
  6. ironpress HTML to PDF. In process. In pure Rust.

Compare jsPDF with the top 3