🌐
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
$ git clone https://github.com/mozilla/pdf.js.git $ cd pdf.js ... Note that we only mention the most relevant files and folders. β”œβ”€β”€ build/ β”‚ β”œβ”€β”€ pdf.mjs - display layer β”‚ β”œβ”€β”€ pdf.mjs.map - display layer's source map β”‚ β”œβ”€β”€ pdf.worker.mjs - core layer β”‚ └── ...

PDF viewer in JavaScript included in Mozilla Firefox

PDF.js is a JavaScript library that renders Portable Document Format (PDF) files using the web standards-compliant HTML5 Canvas. The project is led by the Mozilla Corporation after Andreas Gal launched it (initially … Wikipedia
Factsheet
Original author Andreas Gal
Developer Mozilla
Initial release 2 July 2011 (2011-07-02)
Factsheet
Original author Andreas Gal
Developer Mozilla
Initial release 2 July 2011 (2011-07-02)
🌐
Mozilla
mozilla.github.io β€Ί pdf.js
PDF.js - Home
A general-purpose, web standards-based platform for parsing and rendering PDFs.
🌐
GitHub
github.com β€Ί mozilla β€Ί pdf.js β€Ί releases
Releases Β· mozilla/pdf.js
PDF Reader in JavaScript. Contribute to mozilla/pdf.js development by creating an account on GitHub.
Author Β  mozilla
🌐
npm
npmjs.com β€Ί package β€Ί pdfjs-dist
pdfjs-dist - npm
This is a pre-built version of the PDF.js source code. It is automatically generated by the build scripts. For usage with older browsers/environments, without native support for the latest JavaScript features, please see the legacy/ folder. Please see this wiki page for information about supported browsers/environments. See https://github.com/mozilla/pdf.js for learning and contributing.
      Β» npm install pdfjs-dist
    
Published Β  Nov 29, 2025
Version Β  5.4.449
🌐
GitHub
github.com β€Ί mozilla β€Ί pdfjs-dist
GitHub - mozilla/pdfjs-dist: Generic build of PDF.js library.
Generic build of PDF.js library. . Contribute to mozilla/pdfjs-dist development by creating an account on GitHub.
Starred by 1.3K users
Forked by 568 users
Languages Β  JavaScript 99.2% | CSS 0.8%
🌐
GitHub
github.com β€Ί dealfonso β€Ί pdfjs-viewer
GitHub - dealfonso/pdfjs-viewer: A viewer based on PDFjs, which can be embedded in any web page (not using iframes)
There is a single javascript file that contains the whole PDFjsViewer class (in folder js). There are also a set of css files that contain some styles to be used in the library and examples. These files can also be included individually in your project, or combined into a single file by concatenating them. A Makefile is provided to create the single all-in-one minified js and css files for the library.
Starred by 79 users
Forked by 6 users
Languages Β  JavaScript 76.3% | Makefile 14.5% | CSS 9.2%
🌐
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.
Minified build of PDF.js library including the viewer. - oci-labs/pdfjs-dist-viewer-min
Starred by 35 users
Forked by 22 users
Languages Β  CSS 72.9% | HTML 20.9% | JavaScript 6.2%
Find elsewhere
🌐
GitHub
github.com β€Ί parallax β€Ί jsPDF
GitHub - parallax/jsPDF: Client-side JavaScript PDF generation for everyone.
Client-side JavaScript PDF generation for everyone. - parallax/jsPDF
Starred by 30.9K users
Forked by 4.8K users
Languages Β  JavaScript 96.4% | TypeScript 2.4% | HTML 1.2%
🌐
GitHub
github.com β€Ί Hopding β€Ί pdf-lib
GitHub - Hopding/pdf-lib: Create and modify PDF documents in any JavaScript environment
You can also download pdf-lib as a UMD module from unpkg or jsDelivr. The UMD builds have been compiled to ES5, so they should work in any modern browser. UMD builds are useful if you aren't using a package manager or module bundler.
Starred by 8.1K users
Forked by 828 users
Languages Β  TypeScript 80.9% | HTML 9.9% | JavaScript 8.5% | Objective-C 0.3% | CSS 0.2% | Starlark 0.1% | Java 0.1%
🌐
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
Some files are hidden, click to show all files Β· https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.6.347/pdf.js Β· https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.6.347/pdf.js.map Β· https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.6.347/pdf.min.js Β·
🌐
GitHub
gist.github.com β€Ί shinoyu β€Ί 340b44bcd686c224a881cda950cf3595
pdf.js sample. Β· GitHub
Clone this repository at <script src="https://gist.github.com/shinoyu/340b44bcd686c224a881cda950cf3595.js"></script> Save shinoyu/340b44bcd686c224a881cda950cf3595 to your computer and use it in GitHub Desktop. Download ZIP Β· pdf.js sample.
🌐
Mozilla
mozilla.github.io β€Ί pdf.js β€Ί examples
PDF.js - Examples
This tutorial shows how PDF.js can be used as a library in a web browser.
🌐
GitHub
github.com β€Ί wojtekmaj β€Ί react-pdf
GitHub - wojtekmaj/react-pdf: Display PDFs in your React app as easily as if they were images.
For React-PDF to work, PDF.js worker needs to be provided. You have several options. ... import { pdfjs } from 'react-pdf'; pdfjs.GlobalWorkerOptions.workerSrc = new URL( 'pdfjs-dist/build/pdf.worker.min.mjs', import.meta.url, ).toString();
Starred by 10.7K users
Forked by 981 users
Languages Β  TypeScript 94.3% | CSS 5.6% | HTML 0.1%
🌐
GitHub
github.com β€Ί bpampuch β€Ί pdfmake β€Ί blob β€Ί master β€Ί build β€Ί pdfmake.min.js.map
pdfmake/build/pdfmake.min.js.map at master Β· bpampuch/pdfmake
Client/server side PDF printing in pure JavaScript - pdfmake/build/pdfmake.min.js.map at master Β· bpampuch/pdfmake
Author Β  bpampuch
🌐
SourceForge
sourceforge.net β€Ί projects β€Ί pdf-js.mirror
PDF.js download | SourceForge.net
This is an exact mirror of the PDF.js project, hosted at https://github.com/mozilla/pdf.js. SourceForge is not affiliated with PDF.js.
Top answer
1 of 1
5

Most of these problems are caused by the fact that you are running your test by opening an html file, thus the browser use the file:// instead of http:// or https://.

A quick "hack" to fix the problem in you situation is to insert the <base href="https://mozilla.github.io"> (HTML base tag) inside the head of your test html file (I used the given example as it is, with no changes inside a blank html document) so that you fool the browser and make it search on the Github for the files.

The "correct" way to test such codes and libraries is to install a local web-server and serve the files from there (usually as http://localhost).

An example of the test I created:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Test</title>
        <meta name="description" content="Testing pdf.js">
        <meta name="author" content="GramThanos">

        <!-- hack code -->
        <base href="https://mozilla.github.io">
    </head>
    <body>
        <script src="//mozilla.github.io/pdf.js/build/pdf.js"></script>

        <h1>PDF.js 'Hello, world!' example</h1>

        <canvas id="the-canvas"></canvas>

        <script type="text/javascript">
            // If absolute URL from the remote server is provided, configure the CORS
            // header on that server.
            var url = 'https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/examples/learning/helloworld.pdf';

            // Loaded via <script> tag, create shortcut to access PDF.js exports.
            var pdfjsLib = window['pdfjs-dist/build/pdf'];

            // The workerSrc property shall be specified.
            pdfjsLib.GlobalWorkerOptions.workerSrc = '//mozilla.github.io/pdf.js/build/pdf.worker.js';

            // Asynchronous download of PDF
            var loadingTask = pdfjsLib.getDocument(url);
            loadingTask.promise.then(function(pdf) {
              console.log('PDF loaded');

              // Fetch the first page
              var pageNumber = 1;
              pdf.getPage(pageNumber).then(function(page) {
                console.log('Page loaded');

                var scale = 1.5;
                var viewport = page.getViewport({scale: scale});

                // Prepare canvas using PDF page dimensions
                var canvas = document.getElementById('the-canvas');
                var context = canvas.getContext('2d');
                canvas.height = viewport.height;
                canvas.width = viewport.width;

                // Render PDF page into canvas context
                var renderContext = {
                  canvasContext: context,
                  viewport: viewport
                };
                var renderTask = page.render(renderContext);
                renderTask.promise.then(function () {
                  console.log('Page rendered');
                });
              });
            }, function (reason) {
              // PDF loading error
              console.error(reason);
            });
        </script>
    </body>
</html>

🌐
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
🌐
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
🌐
GitHub
github.com β€Ί rivy β€Ί js.pdf-lib
GitHub - rivy/js.pdf-lib: Create and modify PDF documents in any JavaScript environment
You can also download pdf-lib as a UMD module from unpkg. The UMD builds have been compiled to ES5, so they should work in any modern browser. UMD builds are useful if you aren't using a package manager or module bundler.
Author Β  rivy