PDFObject is a lightweight JavaScript utility for dynamically embedding PDFs in HTML documents.
Copyright (c) 2008-2020 Philip Hutchison MIT-style license: http://pipwerks.mit-license.org/
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.
- New behavior: Dropping support for IE9 and IE10, which have practically 0 marketshare now.
- New behavior: Now explicitly displaying fallback content for all mobile devices, even "Request Desktop" version of pages in iOS. The reasoning is simple: As of the time of this update, no mobile device (Android, iOS) natively supports embedded PDFs. This change will lead to a consistent experience across all mobile devices. PDFs can be rendered via PDF.js on mobile if embedding on mobile is a critical need. PDF.js is not included with PDFObject.
- New option: Omit inline styles by setting option
omitInlineStyles
totrue
. 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. - New option: Suppress console logging by setting option
suppressConsole
totrue
. 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. - New option: Force PDFObject to embed the PDF in an iframe (instead of an
<embed>
) by settingforceIframe
totrue
. - Refactored to use more modern code conventions, such as
let
in lieu ofvar
,el.classList.add()
in place ofel.className = 'foo'
, andmyvar === undefined
in place oftypeof myvar === "undefined"
. Implemented alet
declaration before each variable instead of the Crockford practice of onevar
per function. - New option: On macOS systems, Safari does not properly embed PDFs that have been requested via 302 URL redirection when embedding using the
<embed>
element. SettingsupportRedirect
totrue
forces PDFObject to use an<iframe>
instead of an<embed>
for desktop Safari. Hat tip to John Hunter for the discovery and fix. - Refactored to make code safer for server-side node.js-based environments.
- Refactored to eliminate string-based element creation via
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 viainnerHTML
. - Removed iframe scrollfix for iOS, as it is no longer needed as of iOS13. iOS 12 and lower have ~5-7% marketshare and shrinking fast.
- Refactored codebase to make it more concise and legible.
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.