DocsVueGetting Started

Getting Started

Let’s build a basic, scrollable PDF viewer in Vue. This guide will walk you through the essential setup.

1. Installation

You’ll need a few packages to create a minimal viewer: the core library, the engine, and a few essential plugins.

npm install @embedpdf/core @embedpdf/engines @embedpdf/plugin-document-manager @embedpdf/plugin-viewport @embedpdf/plugin-scroll @embedpdf/plugin-render

2. Create Your Viewer Component

The core of your viewer will be the <EmbedPDF> component, which manages the engine and plugins. This example uses Vue 3’s <script setup> syntax.

Here is a minimal PDFViewer component that loads a document from a URL and renders it in a vertically scrollable viewport.

PDFViewer.vue
<script setup lang="ts"> import { usePdfiumEngine } from '@embedpdf/engines/vue'; import { EmbedPDF } from '@embedpdf/core/vue'; import { createPluginRegistration } from '@embedpdf/core'; // Import the essential plugins import { ViewportPluginPackage, Viewport } from '@embedpdf/plugin-viewport/vue'; import { ScrollPluginPackage, Scroller } from '@embedpdf/plugin-scroll/vue'; import { DocumentContent, DocumentManagerPluginPackage, } from '@embedpdf/plugin-document-manager/vue'; import { RenderLayer, RenderPluginPackage } from '@embedpdf/plugin-render/vue'; // 1. Initialize the engine with the Vue composable const { engine, isLoading } = usePdfiumEngine(); // 2. Register the plugins you need const plugins = [ createPluginRegistration(DocumentManagerPluginPackage, { initialDocuments: [{ url: 'https://snippet.embedpdf.com/ebook.pdf' }], }), createPluginRegistration(ViewportPluginPackage), createPluginRegistration(ScrollPluginPackage), createPluginRegistration(RenderPluginPackage), ]; </script> <template> <div v-if="isLoading || !engine" class="loading-pane"> Loading PDF Engine... </div> <!-- 3. Wrap your UI with the <EmbedPDF> provider --> <div v-else style="height: 500px"> <EmbedPDF :engine="engine" :plugins="plugins" v-slot="{ activeDocumentId }"> <DocumentContent v-if="activeDocumentId" :document-id="activeDocumentId" v-slot="{ isLoaded }" > <Viewport v-if="isLoaded" :document-id="activeDocumentId" style="background-color: #f1f3f5" > <Scroller :document-id="activeDocumentId"> <template #default="{ page }"> <div :style="{ width: page.width + 'px', height: page.height + 'px' }"> <!-- The RenderLayer is responsible for drawing the page --> <RenderLayer :document-id="activeDocumentId" :page-index="page.pageIndex" /> </div> </template> </Scroller> </Viewport> </DocumentContent> </EmbedPDF> </div> </template> <style scoped> .loading-pane { display: flex; justify-content: center; align-items: center; height: 100%; } </style>

3. Render Your Component

Finally, import and use your new <PDFViewer /> component in your main application file.

App.vue
<script setup lang="ts"> import PDFViewer from './PDFViewer.vue'; </script> <template> <PDFViewer /> </template>

Interactive Example

When you run the code above, it will produce a functional, scrollable PDF viewer like the one shown here:

You now have a functional PDF viewer!

Next Steps

Last updated on December 5, 2025

Need Help?

Join our community for support, discussions, and to contribute to EmbedPDF's development.