jsPDF is a JavaScript library for generating PDFs on the client side.
The library addresses the need to create PDF documents directly in the browser without server-side processing. It works by providing an API to construct PDF content programmatically, supporting various paper sizes, orientations, and units. Users can add text, images, and other content to PDF documents and then save or download them. The library includes an optional html method that can convert HTML content to PDF, which depends on html2canvas and optionally dompurify for sanitization.
jsPDF suits projects where PDF generation must happen in the browser, such as invoice generators, report builders, or document export features in web applications. It offers multiple module formats to accommodate different environments: ES2015 modules for modern bundlers, UMD format for AMD or script-tag loading, and Node.js-specific builds for server-side use. The library includes polyfills for older browsers like Internet Explorer. Developers should be aware that the library requires sanitization of user input before passing it to jsPDF for security reasons. Optional dependencies like html2canvas are loaded dynamically, allowing build tools to create separate chunks and preventing unnecessary bloat if those features are unused. When running under Node.js, the library restricts local file system access by default and recommends using Node's permission flags for enforced security rather than the fallback allowFsRead option.
The project is co-maintained by yWorks, a company specializing in diagramming software. The repository maintains a live demo and documentation accessible through the project's GitHub pages. The codebase is distributed through npm and unpkg, with clear guidance on which build variant to use depending on the module system and environment.