Export Plugin

The Export Plugin provides a simple way for users to download and save the PDF file they are viewing.

Installation

The plugin is available as a separate NPM package.

npm install @embedpdf/plugin-export

Registration

Import ExportPluginPackage and add it to the plugins array. You can configure a fallback filename for the downloaded file.

import { createPluginRegistration } from '@embedpdf/core' // ... other imports import { ExportPluginPackage } from '@embedpdf/plugin-export/vue' const plugins = [   // ... other essential plugins   createPluginRegistration(LoaderPluginPackage, { /* ... */ }),   createPluginRegistration(ViewportPluginPackage),   createPluginRegistration(ScrollPluginPackage),   createPluginRegistration(RenderPluginPackage),   // Register the export plugin   createPluginRegistration(ExportPluginPackage, {     defaultFileName: 'my-document.pdf',   }), ]

Usage

The plugin works by combining a composable for initiating the download with a component that handles the browser interaction.

Triggering a Download

Use the useExportCapability composable to get access to the plugin’s download method. Call this method from a button in your toolbar to start the download process.

<script setup lang="ts"> import { useExportCapability } from '@embedpdf/plugin-export/vue'; const { provides: exportApi } = useExportCapability(); </script> <template> <button @click="exportApi?.download()" :disabled="!exportApi"> Download </button> </template>

Live Example

This example shows a viewer with a download button. Clicking it will trigger a download of the PDF file.

API Reference

Configuration (ExportPluginConfig)

OptionTypeDescription
defaultFileNamestringA fallback filename to use for the downloaded file if the original document does not have a name.
Default: document.pdf

Composable: useExportCapability()

This composable connects your component to the export plugin’s functions.

Returns

PropertyTypeDescription
providesRef<ExportCapability | null>A ref object with methods to control exporting, or null if the plugin is not ready.

ExportCapability Methods

MethodDescription
download()The primary method to trigger a download. It signals the auto-mounted <Download /> component to prepare the file and prompt the user.
saveAsCopy()A lower-level method that returns a Task<ArrayBuffer>. It retrieves the document’s data as an ArrayBuffer without triggering a download. Useful for custom export logic.
Last updated on October 8, 2025

Need Help?

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