A lightweight JavaScript utility for dynamically embedding PDFs in HTML documents.
See the codeA lightweight JavaScript utility for dynamically embedding PDFs in HTML documents.
Examples and documentation can be found at https://pdfobject.com.
A PDFObject component for Vue.js 3 can be found at https://github.com/pipwerks/pdfobject-vue/
Copyright (c) 2008-2025 Philip Hutchison
MIT-style license: http://pipwerks.mit-license.org/
fallbackFileNameForBase64 option. If the browser doesn't support PDF embeds, and the PDF is a base64 file, this option will enable the developer to specify the filename for the downloaded PDF. Previously, the filename was hardcoded to 'file.pdf'. Thanks to Joshua Newall (@imjosh) for the contribution.<embed> in favor of <iframe>. PDFObject had previously defaulted to an <embed> element, but over time it has become apparent the superior solution is <iframe>. It's universally supported, and does not suffer from <embed>'s odd quirks and spotty support. This should make PDFObject more consistent and robust across platforms.<embed> and redefining the detection logic, some PDFObject options have become obsolete. They are safe to keep in your code (will not throw errors), but are no longer used by PDFObject. The deprecated options are: assumptionMode, forceIframe, and supportRedirect.navigator.pdfViewerEnabled, per #290. As of Spring 2023, navigator.pdfViewerEnabled is supported in all major browsers. This naturally led to redefining PDFObject's PDF support detection logic.
navigator.pdfViewerEnabled.navigator.pdfViewerEnabled is found and set to true, PDFObject will embed the PDF.navigator.pdfViewerEnabled is not found, fallback logic will kick in and check what kind of browser is being used.page is always set if comment, viewrect or highlight are specified.Refactored one line of code to restore IE11 compatibility, per #287.
Typo in version number within PDFObject code. Yup, I'm a bit rusty.
Version bump for cleaning up docs and aligning on NPM. I'm a bit rusty.
pdfOpenParams handling, resolves issue #272. Hat tip to Theo Beers.embed and iframe elements, per #274fallbackLink handling to ensure false is respected. Hat tip to Theo Beers.title attribute to PDFJS iframe elements per #258title attribute to embed and iframe elements per #248assumptionMode is enabled. However assumptionMode will still be available for browsers that are not declared modern.allow="fullscreen" attribute to iframe embeds, in case anyone needs their PDFs to be rendered fullscreen.Reinstated typeof check for window to play nice with React and NextJS.
Version bump for NPM. Sigh.
Fixed typo affecting suppressConsole functionality. Hat tip to John Hunter for the discovery and fix.
Fixed typo affecting styling of iframe when forcing PDFJS.
omitInlineStyles to true. This helps developers who use strict environments where inline styles are not allowed. Note you will be responsible for applying proper styling via your own CSS.suppressConsole to true. PDFObject currently places error messages in the console if the PDF can't be embedded for some reason. This option allows you to mute those alerts.<embed>) by setting forceIframe to true.let in lieu of var, el.classList.add() in place of el.className = 'foo', and myvar === undefined in place of typeof myvar === "undefined". Implemented a let declaration before each variable instead of the Crockford practice of one var per function.<embed> element. Setting supportRedirect to true forces PDFObject to use an <iframe> instead of an <embed> for desktop Safari. Hat tip to John Hunter for the discovery and fix.innerHTML. Replaced with standard DOM methods. This helps alleviate unforeseen issues with file names. Only exception is insertion of fallback content, which is passed as a string via innerHTML.Improved handling of iOS to properly indicate iOS does not support embedded PDFs.
Changed assumptionMode default from false to true. This will ensure PDFObject 2.x will work for Firefox users without requiring them to change their codebase to enable assumptionMode. All they need to do is load the latest version of PDFObject, the PDFObject utility will take care of the rest.
January 2017: Modified to support Mozilla's removal of navigator.mimeTypes inspection. Added assumptionMode for manual override of PDFObject's default navigator.mimeTypes sniffing.
Initial release of PDFObject 2.0. Contains breaking changes, and is not compatible with PDFObject 1.x.
Overall
Maintained
Code review
npm
Latest release
Releases this year
414 followers · starred Aug 2019
56 followers · starred Feb 2024
69 followers · starred Feb 2019
510 followers · starred Oct 2018
A lightweight JavaScript utility for dynamically embedding PDFs in HTML documents.
See the codeA lightweight JavaScript utility for dynamically embedding PDFs in HTML documents.
Examples and documentation can be found at https://pdfobject.com.
A PDFObject component for Vue.js 3 can be found at https://github.com/pipwerks/pdfobject-vue/
Copyright (c) 2008-2025 Philip Hutchison
MIT-style license: http://pipwerks.mit-license.org/
fallbackFileNameForBase64 option. If the browser doesn't support PDF embeds, and the PDF is a base64 file, this option will enable the developer to specify the filename for the downloaded PDF. Previously, the filename was hardcoded to 'file.pdf'. Thanks to Joshua Newall (@imjosh) for the contribution.<embed> in favor of <iframe>. PDFObject had previously defaulted to an <embed> element, but over time it has become apparent the superior solution is <iframe>. It's universally supported, and does not suffer from <embed>'s odd quirks and spotty support. This should make PDFObject more consistent and robust across platforms.<embed> and redefining the detection logic, some PDFObject options have become obsolete. They are safe to keep in your code (will not throw errors), but are no longer used by PDFObject. The deprecated options are: assumptionMode, forceIframe, and supportRedirect.navigator.pdfViewerEnabled, per #290. As of Spring 2023, navigator.pdfViewerEnabled is supported in all major browsers. This naturally led to redefining PDFObject's PDF support detection logic.
navigator.pdfViewerEnabled.navigator.pdfViewerEnabled is found and set to true, PDFObject will embed the PDF.navigator.pdfViewerEnabled is not found, fallback logic will kick in and check what kind of browser is being used.page is always set if comment, viewrect or highlight are specified.Refactored one line of code to restore IE11 compatibility, per #287.
Typo in version number within PDFObject code. Yup, I'm a bit rusty.
Version bump for cleaning up docs and aligning on NPM. I'm a bit rusty.
pdfOpenParams handling, resolves issue #272. Hat tip to Theo Beers.embed and iframe elements, per #274fallbackLink handling to ensure false is respected. Hat tip to Theo Beers.title attribute to PDFJS iframe elements per #258title attribute to embed and iframe elements per #248assumptionMode is enabled. However assumptionMode will still be available for browsers that are not declared modern.allow="fullscreen" attribute to iframe embeds, in case anyone needs their PDFs to be rendered fullscreen.Reinstated typeof check for window to play nice with React and NextJS.
Version bump for NPM. Sigh.
Fixed typo affecting suppressConsole functionality. Hat tip to John Hunter for the discovery and fix.
Fixed typo affecting styling of iframe when forcing PDFJS.
omitInlineStyles to true. This helps developers who use strict environments where inline styles are not allowed. Note you will be responsible for applying proper styling via your own CSS.suppressConsole to true. PDFObject currently places error messages in the console if the PDF can't be embedded for some reason. This option allows you to mute those alerts.<embed>) by setting forceIframe to true.let in lieu of var, el.classList.add() in place of el.className = 'foo', and myvar === undefined in place of typeof myvar === "undefined". Implemented a let declaration before each variable instead of the Crockford practice of one var per function.<embed> element. Setting supportRedirect to true forces PDFObject to use an <iframe> instead of an <embed> for desktop Safari. Hat tip to John Hunter for the discovery and fix.innerHTML. Replaced with standard DOM methods. This helps alleviate unforeseen issues with file names. Only exception is insertion of fallback content, which is passed as a string via innerHTML.Improved handling of iOS to properly indicate iOS does not support embedded PDFs.
Changed assumptionMode default from false to true. This will ensure PDFObject 2.x will work for Firefox users without requiring them to change their codebase to enable assumptionMode. All they need to do is load the latest version of PDFObject, the PDFObject utility will take care of the rest.
January 2017: Modified to support Mozilla's removal of navigator.mimeTypes inspection. Added assumptionMode for manual override of PDFObject's default navigator.mimeTypes sniffing.
Initial release of PDFObject 2.0. Contains breaking changes, and is not compatible with PDFObject 1.x.
Overall
Maintained
Code review
npm
Latest release
Releases this year
414 followers · starred Aug 2019
56 followers · starred Feb 2024
69 followers · starred Feb 2019
510 followers · starred Oct 2018