jsPDF: Client-side JavaScript PDF generation
Generate PDF documents in-browser with JavaScript APIs.
Learn more about jsPDF
jsPDF is a JavaScript library for creating PDF documents programmatically in client-side environments. It works by providing a JavaScript API that constructs PDF files according to the PDF specification, allowing developers to add content like text, shapes, and images directly in the browser. The library supports multiple module formats including ES2015, UMD, AMD, and Node.js variants, with optional dependencies for advanced features like HTML-to-PDF conversion. Common use cases include generating invoices, reports, and certificates on demand without requiring backend PDF generation services.
Universal Module Support
Ships with ES2015, UMD, AMD, and Node.js variants in a single package. Build tools automatically select the correct format without configuration, ensuring compatibility across different JavaScript environments and bundlers.
Dynamic Dependency Loading
Advanced features like HTML rendering and DOM sanitization load only when invoked. Keeps base bundle size minimal by excluding unused functionality, reducing initial load time for applications that need basic PDF generation.
Flexible Document Configuration
Supports custom page sizes, orientations, and units with fine-grained control over margins, headers, and footers. Generate documents matching specific print requirements or corporate templates programmatically.
import { jsPDF } from "jspdf";
const doc = new jsPDF();
doc.text("Invoice #12345", 10, 10);
doc.text("Total: $99.99", 10, 20);
doc.save("invoice.pdf");Fixes critical PNG encoding regressions introduced in v3.0.2; upgrade immediately if using PNG images.
- –Upgrade to resolve broken PNG rendering and form object scaling issues from v3.0.2.
- –Patch also fixes division-by-zero crash when calculating word spacing in text layout.
Patches a DoS vulnerability in PNG parsing (GHSA-8mvj-3j78-4qmw); removes atob/btoa dependencies and adds fast-png.
- –Upgrade immediately to fix corrupt PNG images causing infinite loops in addImage method.
- –Note that atob and btoa dependencies are removed; fast-png is now required for PNG handling.
Patches a ReDoS vulnerability in addImage, html, and addSvgAsImage methods; upgrades canvg to 3.0.11.
- –Update immediately to fix ReDoS in addImage and dependent methods (html, addSvgAsImage).
- –Upgrade optional canvg dependency to 3.0.11 if your project uses it.
See how people are using jsPDF
Top in Developer Tools
Related Repositories
Discover similar tools and frameworks used by developers
husky
Manage Git hooks via Node.js package.
ts-node
Execute TypeScript directly without precompilation step.
pino
Low-overhead streaming JSON logger for Node.js.
pybind11
Header-only library creating minimal-boilerplate C++ Python bindings.
corepack
Enforces package manager versions specified in package.json.