unpdf is a modern, actively maintained PDF extraction and rendering library that runs across all JavaScript runtimes: Node.js, Deno, Bun, browsers, and serverless environments like Cloudflare Workers. Version 1.6.2 ships a serverless build of Mozilla's PDF.js v5.6.205, optimized for edge computing. It provides high-level APIs for extracting text, links, and images from PDF files, making it ideal for AI applications that require PDF summarization or analysis. Unlike older libraries like pdf-parse, unpdf supports ESM, TypeScript natively, and eliminates the need for external worker files in serverless contexts. It offers opt-in support for official or legacy PDF.js builds and includes a peer dependency on @napi-rs/canvas for rendering operations.
npm install unpdfNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage of unpdf to fetch a PDF, load it, extract text, and log the result. Assumes an environment with fetch and async/await.
Use the bundled serverless build (default) or upgrade Node.js to >=22.
Use getResolvedPDFJS() instead of importing from 'unpdf/pdfjs'.
Ensure you await every call: const pdf = await getDocumentProxy(...); const { text } = await extractText(pdf);Use import statements or dynamic import() in CommonJS modules.
Always await definePDFJSModule(...) at the top of your module.
Use: const { getDocument } = await getResolvedPDFJS();Use: import { extractText } from 'unpdf'Switch to import syntax or use dynamic import: const unpdf = await import('unpdf')Use the bundled serverless build (default) or upgrade Node.js version.