Mozilla
mozilla.github.io › pdf.js
PDF.js - Home
A general-purpose, web standards-based platform for parsing and rendering PDFs.
Nunjucks
Grab nunjucks.js (min) for the full library, or grab nunjucks-slim.js (min) for a slim version that only works with precompiled templates.
API
A general-purpose, web standards-based platform for parsing and rendering PDFs.
Examples
A general-purpose, web standards-based platform for parsing and rendering PDFs.
Getting started
A general-purpose, web standards-based platform for parsing and rendering PDFs.
cdnjs
cdnjs.com › home › libraries › pdf.js › 2.6.347
pdf.js - Libraries - cdnjs - The #1 free and open source CDN built to make life easier for developers
https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.6.347/pdf.min.js · https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.6.347/pdf.worker.entry.js · https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.6.347/pdf.worker.entry.min.js · https://cdnjs....
Videos
SourceForge
sourceforge.net › projects › pdf-js.mirror
PDF.js download | SourceForge.net
Download PDF.js for free. A PDF Reader in JavaScript. PDF.js is a web standards-based platform for parsing and rendering Portable Document Formats (PDFs). Open source and built with HTML5, this PDF viewer is supported by a great community and Mozilla Labs.
GitHub
github.com › mozilla › pdf.js
GitHub - mozilla/pdf.js: PDF Reader in JavaScript
If everything worked out, install all dependencies for PDF.js: ... Finally, you need to start a local web server as some browsers do not allow opening PDF files using a file:// URL. Run: ... Please keep in mind that this assumes the latest version of Mozilla Firefox; refer to Building PDF.js for non-development usage of the PDF.js library.
Starred by 52.4K users
Forked by 10.5K users
Languages JavaScript 71.3% | Fluent 25.5% | CSS 2.2%
Mozilla
mozilla.github.io › pdf.js › getting_started
PDF.js - Getting Started
An introduction to PDF.js with examples. Before downloading PDF.js please take a moment to understand the different layers of the PDF.js project.
UNPKG
app.unpkg.com › [email protected] › files › build
UNPKG
Generic build of Mozilla's PDF.js library.
CDNPKG
cdnpkg.com › home › pdf.js › pdf.min.js
PDF.MIN.JS: DOWNLOAD - CDNPKG
Download pdf.min.js or get a CDN url for 1510 versions of pdf.js.
npm
npmjs.com › package › pdfjs-dist
pdfjs-dist - npm
Generic build of Mozilla's PDF.js library.. Latest version: 5.4.449, last published: 12 days ago. Start using pdfjs-dist in your project by running `npm i pdfjs-dist`. There are 2279 other projects in the npm registry using pdfjs-dist.
» npm install pdfjs-dist
Published Nov 29, 2025
Version 5.4.449
Repository https://github.com/mozilla/pdf.js
Homepage https://mozilla.github.io/pdf.js/
jsDelivr
jsdelivr.com › package › npm › pdfjs-dist-min
pdfjs-dist-min CDN by jsDelivr - A CDN for npm and GitHub
May 17, 2023 - A free, fast, and reliable CDN for pdfjs-dist-min. Generic build of Mozilla's PDF.js library.
Published May 17, 2023
Repository https://github.com/to-na/pdfjs-dist-min
jsDelivr
jsdelivr.com › package › npm › pdfjs-dist-viewer-min
pdfjs-dist-viewer-min CDN by jsDelivr - A CDN for npm and GitHub
July 13, 2024 - A free, fast, and reliable CDN for pdfjs-dist-viewer-min. Generic minified build of Mozilla's PDF.js library including the viewer component.
Published Jun 19, 2016
Top answer 1 of 7
88
Use the download attribute.
var link = document.createElement('a');
link.href = url;
link.download = 'file.pdf';
link.dispatchEvent(new MouseEvent('click'));
2 of 7
14
It is also possible to open the pdf link in a new window and let the browser handle the rest:
window.open(pdfUrl, '_blank');
or:
window.open(pdfUrl);
GitHub
github.com › parallax › jsPDF
GitHub - parallax/jsPDF: Client-side JavaScript PDF generation for everyone.
Recommended: get jsPDF from npm: npm install jspdf --save # or yarn add jspdf · Alternatively, load it from a CDN: <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/3.0.4/jspdf.umd.min.js"></script> Or always get latest version via unpkg ·
Starred by 30.9K users
Forked by 4.8K users
Languages JavaScript 96.4% | TypeScript 2.4% | HTML 1.2%
Top answer 1 of 3
4
You have to set GlobalWorkerOptions.workerSrc to /build/pdf.worker(.min).js of same version:
pdfjsLib.GlobalWorkerOptions.workerSrc =
"https://cdn.jsdelivr.net/npm/[email protected]/build/pdf.worker.min.js";
pdfjsLib.getDocument('./ahmed.pdf').promise.then(doc => {
console.log(`This document has ${doc._pdfInfo.numPages} pages.");
});
And, as @Pasi has mentioned, you have to promisify .getDocument() by chaining .promise on it. Without it, there is no .then().
2 of 3
1
See the "Hello World with document load error handling" example on this page to get started: https://mozilla.github.io/pdf.js/examples/
(Your snippet is missing .promise after getDocument() and setting the workerSrc property)
CDNPKG
cdnpkg.com › home › pdf.js › pdf.worker.min.js
PDF.WORKER.MIN.JS: DOWNLOAD - CDNPKG
Download pdf.worker.min.js or get a CDN url for 1510 versions of pdf.js.
GitHub
github.com › oci-labs › pdfjs-dist-viewer-min
GitHub - oci-labs/pdfjs-dist-viewer-min: Minified build of PDF.js library including the viewer.
Starred by 35 users
Forked by 22 users
Languages CSS 72.9% | HTML 20.9% | JavaScript 6.2%
PDF-LIB
pdf-lib.js.org
PDF-LIB · Create and modify PDF documents in any JavaScript environment.
https://cdn.jsdelivr.net/npm/[email protected]/dist/pdf-lib.min.js