PDFObject is a lightweight JavaScript utility designed for embedding PDF documents directly into HTML pages. Currently at version 2.3.1, it provides a robust solution for displaying PDFs inline across various browsers. The project maintains a steady release cadence, with significant updates (like 2.3) introducing major architectural changes approximately annually, alongside minor patches for fixes and enhancements. A key differentiator is its shift to a pure `<iframe>` approach in v2.3, abandoning the less consistent `<embed>` element, which enhances cross-browser compatibility and reliability. It also intelligently leverages `navigator.pdfViewerEnabled` to determine native PDF viewing capabilities and automatically falls back to download options on unsupported platforms, especially mobile devices. This makes it a pragmatic choice for integrating PDF content without external plugins.
npm install pdfobjectVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to embed a PDF directly into an HTML element using PDFObject's `embed` method, including feature detection and fallback content.
Ensure your CSS and JavaScript targeting embedded PDFs uses `iframe` selectors instead of `embed`. The `id` option for the embedded element remains supported for targeting.
Remove deprecated options from your `PDFObject.embed()` calls. They will be safely ignored but serve no function.
Design your fallback content appropriately for mobile users, such as a download link. Do not expect inline PDF display on phones or tablets.
Ensure your application handles the fallback scenario gracefully, providing clear instructions or a download option for users with disabled PDF viewers.
Upgrade to PDFObject v2.3.1 or higher and use the new `fallbackFileNameForBase64` option to specify a custom filename for downloaded base64 PDFs when inline embedding fails.
PDFObject's design anticipates this and provides fallback content. Ensure you have `fallbackLink` or `fallbackContent` configured for unsupported scenarios. Users will be prompted to download the PDF instead.
Remove these deprecated options from your `PDFObject.embed()` calls. The library now defaults to an `<iframe>` and handles detection automatically, rendering these options unnecessary.
Upgrade to PDFObject v2.2.9 or higher. Ensure your `pdfOpenParams` are correctly formatted according to Adobe's PDF Open Parameters specification, e.g., `{ page: '2', view: 'FitV' }`.Upgrade to PDFObject v2.3.1 or later. Use the `fallbackFileNameForBase64` option in your `PDFObject.embed()` call to specify the desired filename, for example: `PDFObject.embed(base64Data, '#container', { fallbackFileNameForBase64: 'MyDocument.pdf' });`No dependency data recorded yet.