@fiscozen/pdf-viewer

中文文档
1.0.15发布于 2026/10/23MITES Module近 30 天下载 2301

Design System PdfViewer component

原始使用文档
文档目录9 节
  1. Installation
  2. Usage
  3. Props
  4. v-model
  5. Events
  6. Examples
  7. Basic toolbar
  8. Advanced toolbar with download
  9. PDF/XML toggle

@fiscozen/pdf-viewer

Vue 3 component for rendering PDF files with zoom, page navigation, and optional PDF/XML view mode toggle.

Installation

npm install @fiscozen/pdf-viewer

Usage

<script setup>
import { FzPdfViewer } from '@fiscozen/pdf-viewer'
</script>

<template>
  <FzPdfViewer src="https://example.com/document.pdf" width="100%" />
</template>

Props

PropTypeDefaultDescription
srcstring—Required. URL of the PDF file.
xmlSrcstring—URL of the XML file. When provided alongside toolbarVariant="advanced", enables the PDF/XML view mode toggle. In XML mode, the XML is rendered in an iframe and zoom/page controls are hidden.
environment"frontoffice" | "backoffice""frontoffice"Environment variant for sizing.
heightstring"768px"Height of the viewer container.
widthstring"512px"Width of the viewer container.
toolbarVariant"basic" | "advanced""basic""basic" shows zoom and page navigation. "advanced" adds download button and, when xmlSrc is provided, a PDF/XML view mode toggle.
toolbarPosition"top" | "bottom""bottom"Position of the toolbar relative to the PDF. When "top", the toolbar is only revealed on hover.
initialPagenumber1Starting page.
initialScalenumber1Starting zoom level (1 = 100%).
minScalenumber0.25Minimum zoom level.
maxScalenumber2Maximum zoom level.
scaleStepnumber0.25Zoom increment per step.
selectablebooleanfalseWhen true, renders a text layer that allows users to select and copy text.
rotatablebooleanfalseWhen true, shows a rotate button in the advanced toolbar. Only applies when toolbarVariant="advanced".
containerClassstring—Custom CSS class for the outer container.
pdfContainerClassstring—Custom CSS class for the PDF/content container.

v-model

ModelTypeDefaultDescription
viewMode"pdf" | "xml""pdf"Current view mode. Only active when toolbarVariant="advanced" and xmlSrc is provided.

Events

EventPayloadDescription
download—Emitted when the download button is clicked. The parent is responsible for handling the actual download (e.g. downloading PDF or XML depending on current viewMode).

Examples

Basic toolbar

<FzPdfViewer
  src="https://example.com/document.pdf"
  width="100%"
/>

Advanced toolbar with download

<FzPdfViewer
  src="https://example.com/document.pdf"
  toolbarVariant="advanced"
  width="100%"
  @download="handleDownload"
/>

PDF/XML toggle

When xmlSrc is provided alongside toolbarVariant="advanced", the component shows a tab switcher to toggle between PDF view and XML view. In XML mode, the XML is rendered in an iframe; zoom and page controls are hidden while the download button remains visible.

<script setup>
import { ref } from 'vue'
import { FzPdfViewer } from '@fiscozen/pdf-viewer'

const viewMode = ref('pdf')

function handleDownload() {
  const url = viewMode.value === 'pdf' ? pdfUrl : xmlUrl
  // trigger download...
}
</script>

<template>
  <FzPdfViewer
    src="https://example.com/document.pdf"
    xmlSrc="https://example.com/document.xml"
    toolbarVariant="advanced"
    v-model:viewMode="viewMode"
    width="100%"
    @download="handleDownload"
  />
</template>

Note: The download event does not automatically download anything. Use viewMode to determine whether to download the PDF or the XML.

版本与发布记录

@fiscozen/pdf-viewer 共发布 23 个版本,首次发布于 2024/12/13;过去 12 个月发布了 21 个版本。

版本发布日期距今
1.0.15latest2026/10/2323 天前
1.0.142026/10/2026 天前
1.0.132026/10/141 个月前
1.0.122026/10/071 个月前
1.0.112026/09/291 个月前
1.0.102026/09/142 个月前

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

@fiscozen/pdf-viewer 是什么?

Design System PdfViewer component

如何安装 @fiscozen/pdf-viewer?

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

@fiscozen/pdf-viewer 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/fiscozen__pdf-viewer 是否存在。

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

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@fiscozen/pdf-viewer 可以商用吗?

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

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

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

@fiscozen/pdf-viewer 还在维护吗?

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