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");Security-focused release fixing multiple vulnerabilities including PDF injection and XSS.
- –Upgrade optional dompurify dependency to 3.3.1
- –Fix PDF Injection in AcroForm module allows Arbitrary JavaScript Execution vulnerability
- –Fix Stored XMP Metadata Injection (Spoofing & Integrity Violation) vulnerability
- –Fix Shared State Race Condition in addJS Method vulnerability
- –Fix Denial of Service (DoS) via Unvalidated BMP Dimensions in BMPDecoder vulnerability
Critical security release fixing path traversal vulnerability with restricted file system access.
- –This release fixes a critical path traversal/local file inclusion security vulnerability in the jsPDF Node.js build
- –File system access is now restricted by default and can be enabled by either using node's `--permission` flag or the new `jsPDF.allowFsRead` property
Bug fixes for font state management, cell alignment, and TypeScript improvements.
- –fix: cell function now properly accepts align parameter
- –Remove duplicated function "ga" from WebPDecoder.js
- –Fix font state management issue
- –Fix pages property to always return current array reference
See how people are using jsPDF
Top in Developer Tools
Related Repositories
Discover similar tools and frameworks used by developers
tldr-pages
Community-maintained concise help pages for CLI tools with practical examples.
n
A command-line utility for installing, switching between, and managing multiple Node.js versions on Unix-like systems.
Instaloader
Python CLI for downloading Instagram posts, stories, profiles, and metadata.
Biome
Unified toolchain providing fast formatting and linting for JavaScript, TypeScript, CSS, and JSON with CLI and LSP.
Pygame
Python wrapper for SDL enabling 2D game development.