The `pdf-viewer-vue` package offers a straightforward Vue component for embedding and displaying PDF documents directly within Vue 2 and Vue 3 applications. It acts as a wrapper around the `vue-pdf` library, which itself leverages Mozilla's PDF.js for rendering PDF content. The current stable version is 0.2.7. This library is designed for developers seeking a basic, easy-to-integrate PDF viewer without the need for extensive customization or advanced interactive features like sophisticated annotations or form filling, which might be found in more comprehensive or commercially backed alternatives. Its release cadence has been infrequent, focusing primarily on maintaining compatibility with Vue versions 2 and 3.
npm install pdf-viewer-vueVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate and display a PDF document using the PdfViewer component in a Vue 3 Composition API setup, with TypeScript.
For development, use a local proxy or browser extensions to bypass CORS. For production, configure the hosting server (e.g., Apache, Nginx, S3 bucket) to include 'Access-Control-Allow-Origin: *' or specific origins for PDF files.
Always apply `height` and `width` styles to the `<PdfViewer>` component or its parent container. For example: `<PdfViewer :src="pdfUrl" style="height: 500px; width: 100%;" />`.
Refer to the documentation and issue trackers for `vue-pdf` (FranckFreiburger/vue-pdf) and `pdf.js` (mozilla/pdf.js) for deeper insights into rendering problems or advanced configurations.
For new projects, prioritize Vue 3. For existing Vue 2 projects, plan an upgrade path to Vue 3 to ensure long-term support and access to new features.
Verify the `src` prop URL is correct and accessible. If loading from a different domain, ensure the server hosting the PDF has appropriate `Access-Control-Allow-Origin` headers set to allow your application's domain.
Apply inline styles or CSS classes to the `<PdfViewer>` component or its immediate parent to give it a defined `height` and `width`, for example: `<PdfViewer src="..." style="height: 600px; width: 100%;" />`.
Ensure Vue is properly initialized and the `PdfViewer` component is correctly imported and registered within your Vue component's `components` option or via `app.component()` in Vue 3.