vue-pdfz

A customizable, i18n-ready, SSR-safe PDF viewer for Vue
406 2
Install
npm install vue-pdfz
Latest Version:1.0.2
Vue:3
License:MIT
Last Updated:Oct 14, 2026
Links: GitHub  ·  npm
Maintainer: hrynko

vue-pdfz

A customizable, i18n-ready, SSR-safe PDF viewer for Vue

npm Version npm Downloads GitHub Stars License

vue-pdfz screenshot

Features

  • 📖 Continuous, single- and two-page layouts
  • 📝 Text search, links, annotations and forms
  • 🔒 Password-protected files
  • 🖨️ Print and download
  • 🌍 9 built-in locales, RTL and optional vue-i18n integration
  • 🎨 Light and dark themes, design tokens and slots for custom UI
  • ⌨️ Keyboard shortcuts and ARIA labels
  • ⚡ Lazy rendering and optional virtualization
  • 🧩 Typed API, SSR-safe, with Nuxt support

Installation

npm install vue-pdfz

Usage

<script setup>
import { PdfViewer } from 'vue-pdfz'
import 'vue-pdfz/style.css'
</script>

<template>
  <PdfViewer source="/document.pdf" style="height: 600px" />
</template>

Props

Prop Type Default Description
annotationLayer boolean true Render the annotation layer.
enableDownload boolean true Enable the download button and shortcut.
enableKeyboard boolean true Enable keyboard shortcuts.
enablePrint boolean true Enable the print button and shortcut.
enableSearch boolean true Enable text search.
forms boolean | 'readonly' false Interactive AcroForm fields; 'readonly' renders them non-editable.
imageResourcesPath string – URL path to PDF.js annotation icon assets.
layout 'continuous' | 'facing' | 'single' 'continuous' Page layout mode.
lazy boolean true Defer per-page rendering until near the viewport.
linkRel string 'noopener noreferrer' rel attribute for external links.
linkTarget '_blank' | '_parent' | '_self' | '_top' '_blank' target attribute for external links.
locale string plugin / 'en' Active UI locale code.
maxZoom number 10 Maximum zoom scale.
messages Partial<LocaleMessages> – Per-instance string overrides.
minZoom number 0.1 Minimum zoom scale.
page number 1 Current page number. v-model:page.
rotation 0 | 90 | 180 | 270 0 Rotation in degrees. v-model:rotation.
searchControls { caseSensitive?: boolean, entireWord?: boolean } – Which search toggles to show (hidden by default).
shortcuts KeyboardShortcuts – Override key bindings per action.
showThumbnails boolean | 'auto' 'auto' Thumbnails sidebar; 'auto' opens on wide containers, false disables it.
showToolbar boolean true Show the toolbar.
source string | URL | ArrayBuffer | Uint8Array | PdfSource – The PDF to load: URL, binary, or config object.
textLayer boolean true Render the selectable text layer (required for search).
theme 'light' | 'dark' | 'auto' 'light' Color-scheme mode.
themeTokens ThemeTokens – Design-token overrides.
thumbnailWidth number 120 Thumbnail render width in px.
virtualization boolean false Windowed page rendering for large documents.
zoom number | 'auto' | 'page-fit' | 'page-width' 'auto' Zoom level or fit mode. v-model:zoom.
zoomStep number 0.25 Step for zooming in/out.

Events

Event Payload
annotation-click AnnotationClickPayload
error PdfError
form-change FormChangePayload
link-click LinkClickPayload
loaded PdfDocumentMeta
loading-progress LoadingProgress
page-change number (page)
password-incorrect –
password-required –
rendered number (page)
rotation-change Rotation
search-result SearchResult
update:page / update:rotation / update:zoom v-model updates
zoom-change ZoomValue, number (scale)

Slots

Slot Scope Purpose
empty – Empty-state overlay.
error { error, retry } Error overlay.
icon-* – icon-prev, icon-next, icon-zoom-in, icon-zoom-out, icon-rotate-cw, icon-search, icon-print, icon-download, icon-thumbnails
loading { progress } Loading overlay.
page-overlay { pageNumber, scale } Per-page watermarks / badges.
password { submit, error } Password prompt overlay.
search-bar { total, current, search, next, prev, close } Custom search UI.
thumbnail { isActive, page, src } Per-thumbnail item.
thumbnails { goToPage, page, pageCount } Full sidebar replacement.
toolbar-start / toolbar-center / toolbar-end – Replace a toolbar region.
toolbar { page, pageCount, rotation, scale } Full toolbar replacement.

Exposed Methods

const viewer = ref<InstanceType<typeof PdfViewer>>()
viewer.value?.goToPage(1)
viewer.value?.nextPage()
viewer.value?.prevPage()
viewer.value?.setZoom(1)
viewer.value?.zoomIn()
viewer.value?.zoomOut()
viewer.value?.rotate('cw')
const result = await viewer.value?.search('foo')
viewer.value?.nextMatch()
viewer.value?.prevMatch()
viewer.value?.clearSearch()
await viewer.value?.print()
await viewer.value?.download()

Internationalization

Resolution order for any string: vue-i18n adapter (if installed) → per-component messages → plugin messages → built-in bundle for locale → en fallback.

Override individual strings

<PdfViewer :messages="{ download: 'Save' }" />

Add a locale

import { en, type LocaleMessages } from 'vue-pdfz'

const it: LocaleMessages = { ...en, nextPage: 'Pagina successiva' /* ... */ }

// Per instance:
// <PdfViewer locale="it" :messages="it" />

// Or app-wide via the plugin:
// app.use(VuePdfz, { locale: 'it', messages: { it } })

Add an optional vue-i18n adapter

With an adapter to a host vue-i18n instance, keys resolve as ${prefix}${key} (the default prefix is vuePdfz.), with unresolved keys falling back to the built-in bundle.

import { createI18n } from 'vue-i18n'
import VuePdfz, { createVueI18nAdapter } from 'vue-pdfz'

const i18n = createI18n({
  locale: 'en',
  messages: {
    en: {
      vuePdfz: {
        download: 'Export',
      },
    },
  },
})

app.use(i18n).use(VuePdfz, { i18nAdapter: createVueI18nAdapter(i18n.global) })

License

MIT

Related Packages

@xtctwins/tctwins-pdf-core

Reusable PDF core with Vue 3 viewer, tile rendering, annotations (measure/rectan...

771
@pdf-viewer-yee/pdf-viewer-vue3

一款Vue3框架开发的pdf阅读器组件,如果您使用的是Vue2,可以查看Vue2PDF阅读器组件地...

1,669 1
@tuttarealstep/vue-pdf.js

A Vue component for displaying PDF files using the standard `pdf.js` viewer. Thi...

9,888 25
@mecorelabs/free-pdf-sdk

Free PDF SDK: an embeddable, white-label PDF viewer, annotator and editor for th...

207 0
vue-pdf-embed

PDF embed component for Vue

7,595,565 1,044

Version History

Version Released Vue License
1.0.2 ^3.4.0 MIT
1.0.1 ^3.4.0 MIT
1.0.0 ^3.4.0 MIT