@docviewkit/viewer

中文文档
0.2.84发布于 2026/11/10Apache-2.0TypeScriptES Module零依赖构建来源已验证近 30 天下载 2077

Frontend-local, read-only Office, PDF and OFD Viewer Web Component

原始使用文档
文档目录8 节
  1. Why DocViewKit
  2. Where it fits
  3. What your users can do
  4. Supported formats
  5. Get started
  6. Works with your frontend
  7. Open source and professional services
  8. Explore further

DocViewKit Viewer

English · 简体中文

Lightweight document previews. Quick integration. Fits your business.

Give your users a place to read Word, Excel, PowerPoint, PDF, OFD and more inside your application. DocViewKit brings document viewing, search and source location to everyday OA attachments, approval workflows, CRM/ERP, cloud drives and enterprise apps. Documents are parsed and rendered locally in the frontend, with no conversion server to deploy.

Website · Try your files · Documentation · npm

Why DocViewKit

  • Quick to integrate. Start with a ready-made Viewer instead of assembling a preview interface. Navigation, search, zoom and printing are already available.
  • Files stay local. Parsing, rendering and search run in your application's frontend. DocViewKit does not upload documents to a conversion service; your application keeps control of attachment access and permissions.
  • Lightweight by design. A compact core and on-demand format packs keep unused parsers out of the initial load. Pages, slides and spreadsheet viewports are rendered as needed.
  • One viewing experience. Use the same component for modern and legacy Office files, WPS, PDF, OFD, OpenDocument, iWork and other supported formats.
  • Find the source behind a result. Search and jump to relevant content. Connect your application's search results or AI citations to document pages, objects and regions so users can check the original material.
  • Make it your own. Adapt the interface, commands, theme and text watermarks to your product. Use the Engine API for custom rendering and source-object access.
  • Open source, free to use. Viewer, Engine and every implemented format are available under Apache-2.0. Paid services cover support, customization and enterprise delivery.

Where it fits

  • OA, approvals and internal tools: read attachments alongside the task being reviewed.
  • CRM, ERP and customer portals: view contracts, records and business documents within the existing workflow.
  • Cloud drives, enterprise SaaS and AI knowledge bases: preview files and bring search results or citations back to their source.
  • Legal review, audit and public-sector systems: inspect documents and locate supporting passages while using your own access controls.
  • Education and training: read course materials, presentations and assignments in the application.

What your users can do

Browse pages, slides and sheets with navigation, thumbnails, zoom and fullscreen. Search document text, select and copy it, and jump to the relevant content. Add text watermarks to pages, thumbnails and printed output. Choose a full Viewer interface or a minimal document surface that fits your product.

The Viewer is read-only. Your application owns document storage, authorization and business workflows; DocViewKit provides viewing and source location.

Supported formats

Document familyExamples
Modern Microsoft OfficeWord .docx, Excel .xlsx, PowerPoint .pptx, including supported macro-enabled, template and slideshow variants
Legacy Microsoft OfficeWord .doc, Excel .xls, PowerPoint .ppt
WPS Office.wps, .et, .dps
Fixed-layout documentsPDF, OFD 1.0/1.1, XPS and OpenXPS
OpenDocument.odt, .ods, .odp, .odg, plus supported templates and flat XML variants
Apple iWork.pages, .numbers, .key single-file packages
Text and tabular dataCSV and RTF

Compatibility and rendering depth vary by format and document. Try your actual files in the online Demo and check the supported formats and limits. Some legacy iWork paths still return embedded previews; these remain implementation gaps and do not establish native-content rendering or fidelity.

Get started

Install the Viewer:

npm install @docviewkit/viewer

Place it in your page:

<docviewkit-viewer></docviewkit-viewer>

Import it in client code, enable optional formats on demand, and open a File supplied by your application:

import "@docviewkit/viewer";

const viewer = document.querySelector("docviewkit-viewer");
viewer.config = {
  engine: {
    formatPack: () => import("@docviewkit/viewer/extended-formats")
      .then(({ extendedFormatPack }) => extendedFormatPack),
  },
};
await viewer.open(file);

Only the optional format module needed by the document is loaded. Applications limited to OFD can choose ofd-formats instead. Keep the matching Worker, Wasm, font and codec assets with your deployment; the integration guide covers asset hosting and private attachments.

Works with your frontend

Use the same Viewer in JavaScript, React, Vue and Angular applications, across Chrome, Edge, Firefox and Safari. Compatible WebViews also support Electron, Tauri, Ionic and Capacitor. React Native and Flutter applications can embed it through a WebView with the required browser capabilities; see runtime compatibility.

React and Next.js · Vue · Angular

Open source and professional services

DocViewKit Viewer and Engine use Apache-2.0. All implemented formats, Engine APIs, UI customization, minimal mode and text watermarks are available without runtime licenses, domain registration or mandatory branding. Third-party components and fonts retain their own licenses; preserve LICENSE, NOTICE and THIRD_PARTY_NOTICES.md when redistributing the corresponding materials. These terms apply to releases built from this source; older published versions retain their included licenses. Trademark rights are separate.

For integration assistance, document compatibility work, performance tuning, custom interfaces or enterprise deployment, contact [email protected]. Scope, acceptance cases, delivery dates and SLA are agreed for the service.

Explore further

Validate your real documents before adopting the Viewer. Share confidential support files only through an agreed private channel.

版本与发布记录

@docviewkit/viewer 共发布 41 个版本,首次发布于 2026/08/09;过去 12 个月发布了 41 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.2.84latest2026/11/104 天前
0.2.832026/10/2718 天前
0.2.822026/10/2223 天前
0.2.802026/10/2025 天前
0.2.792026/10/1926 天前
0.2.782026/10/1629 天前

关于 @docviewkit/viewer 的常见问题

@docviewkit/viewer 是什么?

Frontend-local, read-only Office, PDF and OFD Viewer Web Component

如何安装 @docviewkit/viewer?

在项目目录运行 npm install @docviewkit/viewer,或使用 pnpm add / yarn add / bun add。

@docviewkit/viewer 支持 TypeScript 吗?

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

@docviewkit/viewer 支持 ESM 还是 CommonJS?

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

@docviewkit/viewer 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@docviewkit/viewer 可以商用吗?

@docviewkit/viewer 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@docviewkit/viewer 的下载量有多少?

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

@docviewkit/viewer 还在维护吗?

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