pdfjs-dist
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
canvas | 2.11.2 | 123 kB | MIT | prod optional | 1 |
path2d-polyfill | 2.1.1 | 10.43 kB | MIT | prod optional |
"pdfjs-dist" is a pre-generated build of Mozilla's PDF.js library. It's designed to parse and render Portable Document Format (PDF) files by utilizing the web standards-based platform of HTML5. The goal of this library is to offer a general solution for handling PDFs in various applications. As it's automatically generated, it saves developers the time and effort of creating their own implementation of the PDF.js source code.
To use the "pdfjs-dist" npm package, you need to install it first in your project using the command npm install pdfjs-dist
. Regarding the implementation, here is a basic usage example:
var pdfjsLib = require('pdfjs-dist');
var pdfPath = 'path_to_your_pdf_file.pdf';
pdfjsLib.getDocument(pdfPath).promise.then(function(doc) {
var totalPages = doc.numPages;
console.log('The document has ' + totalPages + ' page(s).');
});
This code essentially loads a PDF document and logs out the number of pages it contains. Note that you need to replace 'path_to_your_pdf_file.pdf'
with the actual path of your PDF file.
The "pdfjs-dist" documentation, as well as useful information for learning and contributing, can be found at the PDF.js GitHub page. Further support for dealing with older browsers/environments and usage of the legacy/
folder is available on the Frequently Asked Questions wiki page.