PDF.js
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 as an experiment) in 2011.
History and application
PDF.js was originally created as an extension for Firefox and is included in Firefox since 2012 (version 15), and enabled by default since 2013 (version 19). It was added to Firefox for Android in 2023 (version 111).
The project was created to provide a way for viewing PDF documents natively in the web browser, which prevents potential security risks when opening PDF documents outside a browser, as the code for displaying the document is sandboxed in a browser. Its implementation uses the Canvas element from HTML5, which allows for fast rendering speeds.
PDF.js is also used in Thunderbird, ownCloud, Nextcloud, and is available as a browser extension for Google Chrome/Chromium, Pale Moon and SeaMonkey.
It can be integrated or embedded in a web or native application to enable PDF rendering and viewing, and allows advanced usages such as Server-side rendering.
Many web applications, including Dropbox, Slack, and LinkedIn Learning integrate PDF.js to enable previewing PDF documents.
Behavior
According to a benchmark by Mozilla, PDF.js is performant for viewing most common PDF files, while it may have some issues with large or 'graphics-heavy' documents.
PDF.js supports most of the PDF specifications (including form support or XFA), but some features have not been implemented yet, which may impact rendering behavior depending on the features the document uses.
Several PDF/X or optional PDF features that are not supported in PDF.js include:
- ICC Color Profiles
- Spot colors
- Overprint simulation
- Transparency groups (knockout/isolation)
- High-fidelity printing
The PDF.js contributor community also notes that the browser behavior of PDF.js varies with browser support for PDF.js's required features. Performance and reliability will be the best on Chrome and Firefox, which are fully supported and subject to automated testing.
See also
References
External links
- Official website
- "View PDF files in Firefox". Firefox Help. Mozilla.
- Chris Jones; Andreas Gal; et al. (15 June 2011). "pdf.js: Rendering PDF with HTML5 and JavaScript". Andreas Gal's blog.
- Catalin Cimpanu (3 May 2012). "Script of the Day: pdf.js". Softpedia. Archived from the original on 13 January 2015. Retrieved 3 January 2020.