@embedpdf/vue-pdf-viewer

中文文档
2.15.1发布于 2026/09/17MITTypeScriptESM + CJS近 30 天下载 3.4万

Vue component for embedding PDF documents

原始使用文档
文档目录14 节
  1. 📚 Documentation
  2. 🚀 Introduction
  3. Key Features
  4. 📦 Installation
  5. 🛠 Basic Usage
  6. Nuxt 3 Usage
  7. 🎨 Customization
  8. Theme
  9. Disabling Features
  10. ⚙️ Configuration Options
  11. 🔌 Events & Registry
  12. Available Events
  13. 🧩 Headless Mode
  14. 📄 License
EmbedPDF logo

Vue PDF Viewer

The easiest way to embed PDF files in your Vue 3 application with a complete, ready‑to‑use interface.

Documentation Live Demo NPM Version


📚 Documentation

The full walkthrough, advanced examples, and API reference live in our docs site:

👉 https://www.embedpdf.com/vue-pdf-viewer


🚀 Introduction

The @embedpdf/vue-pdf-viewer package provides a complete, production-ready PDF viewing experience for Vue 3 applications.

It is designed to be the fastest way to get a high-quality PDF viewer into your app. You don't need to build toolbars, handle layout logic, or worry about CSS—it just works.

Key Features

  • Ready-to-use UI — Includes a polished toolbar, sidebar, and thumbnails.
  • Responsive — Adapts seamlessly to mobile and desktop screens.
  • Themable — Built-in light/dark modes and support for custom brand colors.
  • Configurable — Easily disable features you don't need (e.g., printing or downloading).
  • TypeScript — Fully typed for a great developer experience.
  • Nuxt Ready — Works seamlessly with Nuxt 3 and SSR.

📦 Installation

npm install @embedpdf/vue-pdf-viewer
# or
pnpm add @embedpdf/vue-pdf-viewer
# or
yarn add @embedpdf/vue-pdf-viewer

🛠 Basic Usage

Import the PDFViewer component and render it with a PDF source.

<template>
  <div style="height: 100vh">
    <PDFViewer
      :config="{
        src: 'https://snippet.embedpdf.com/ebook.pdf',
        theme: { preference: 'light' },
      }"
    />
  </div>
</template>

<script setup>
import { PDFViewer } from '@embedpdf/vue-pdf-viewer';
</script>

That's it! You now have a fully functional PDF viewer.

Nuxt 3 Usage

The component works seamlessly with Nuxt 3. Since it uses browser APIs (Canvas, WebAssembly), wrap it in <ClientOnly> to avoid hydration errors:

<template>
  <ClientOnly>
    <PDFViewer :config="{ src: '/document.pdf' }" />
  </ClientOnly>
</template>

🎨 Customization

Theme

The viewer includes a robust theming system. You can set the preference to 'light', 'dark', or 'system', and even override specific colors to match your brand.

<PDFViewer
  :config="{
    src: '/document.pdf',
    theme: {
      preference: 'system',
      light: {
        accent: {
          primary: '#42b883', // Custom brand color (Vue Green)
        },
      },
    },
  }"
/>

Disabling Features

Easily customize the UI by disabling features you don't need via the disabledCategories option:

<PDFViewer
  :config="{
    src: '/document.pdf',
    disabledCategories: ['annotation', 'print', 'export'],
  }"
/>

Available categories include: zoom, annotation, redaction, document, page, panel, tools, selection, and history.


⚙️ Configuration Options

The config prop accepts the following top-level options:

OptionTypeDescription
srcstringURL or path to the PDF document.
themeobjectTheme configuration (preference, overrides).
tabBar'always' | 'multiple' | 'never'Control visibility of the document tab bar.
disabledCategoriesstring[]Hide specific UI features by category.
i18nobjectConfigure locales and translations.
annotationsobjectConfigure annotation defaults (author, tools).
zoomobjectConfigure default zoom levels and limits.
scrollobjectConfigure scroll direction and logic.

🔌 Events & Registry

We emit standard Vue events for initialization and readiness.

<template>
  <PDFViewer :config="{ src: '/doc.pdf' }" @ready="onReady" />
</template>

<script setup>
function onReady(registry) {
  const engine = registry.getEngine();
  console.log('Engine ready:', engine);
}
</script>

Available Events

  • @init - Emitted when the viewer container is initialized.
  • @ready - Emitted when the plugin registry is ready and plugins are loaded.

🧩 Headless Mode

Need complete control over the UI? Building a custom design system?

Check out our Headless Composables which provide reactive state and logic without the UI:

npm install @embedpdf/core @embedpdf/plugin-zoom ...

Read the Headless Documentation for more details.


📄 License

EmbedPDF is MIT licensed. Commercial use is welcome—just keep the copyright headers intact.

版本与发布记录

@embedpdf/vue-pdf-viewer 共发布 35 个版本,首次发布于 2025/12/12;过去 12 个月发布了 35 个版本。

版本发布日期距今
2.15.1latest2026/09/171 个月前
2.15.02026/08/053 个月前
2.14.42026/06/085 个月前
2.14.32026/05/205 个月前
2.14.22026/04/306 个月前
2.14.12026/04/226 个月前

其他发布通道:next → 2.0.0-next.3。

关于 @embedpdf/vue-pdf-viewer 的常见问题

@embedpdf/vue-pdf-viewer 是什么?

Vue component for embedding PDF documents

如何安装 @embedpdf/vue-pdf-viewer?

在项目目录运行 npm install @embedpdf/vue-pdf-viewer,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:vue(>=3.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@embedpdf/vue-pdf-viewer 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@embedpdf/vue-pdf-viewer 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@embedpdf/vue-pdf-viewer 可以商用吗?

@embedpdf/vue-pdf-viewer 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@embedpdf/vue-pdf-viewer 的下载量有多少?

根据 npm 官方下载统计,@embedpdf/vue-pdf-viewer 在 2026/10/14 – 2026/11/12 这 30 天内被下载 34,129 次,日均约 1,138 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@embedpdf/vue-pdf-viewer 还在维护吗?

最新版本 2.15.1 发布于 2026/09/17(1 个月前);至今共发布 35 个版本,其中过去 12 个月发布了 35 个;首次发布于 2025/12/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。