@compdfkit_pdf_sdk/webviewer

中文文档
3.0.0发布于 2026/10/27TypeScriptCommonJS零依赖近 30 天下载 1.8万

ComPDF WebViewer is a JavaScript PDF SDK for Web apps that need PDF viewing, annotation, editing, forms, signatures, comparison, and security directly in the browser. For teams building broader document workflow products, ComPDFKit also works with

原始使用文档
文档目录13 节
  1. 🚀 Why ComPDF
  2. 🎬 Live Demo
  3. ⚡ Quick Start
  4. 1. Install
  5. 2. Copy the WebViewer assets
  6. 3. Initialize the viewer
  7. 🧩 Key Features
  8. 💡 Use Cases
  9. 🧪 Code Snippets
  10. Vanilla JavaScript example
  11. React example
  12. 🔗 Documentation & Resources
  13. ❤️ Engagement

PDF SDK for Web | View, Annotate, Edit & Render PDFs in the Browser

ComPDF WebViewer is a JavaScript PDF SDK for Web apps that need PDF viewing, annotation, editing, forms, signatures, comparison, and security directly in the browser. For teams building broader document workflow products, ComPDFKit also works with ComPDF API for Convert, OCR, and Generate workflows.

🚀 Why ComPDF

ComPDF is a practical choice for web teams that need more than a low-level PDF renderer but do not want to build a full document UI stack from scratch.

Why developers use it:

  • Browser rendering: render PDFs directly in the browser with a ready-to-use UI.
  • No backend required for standalone mode: deploy with WebAssembly and keep rendering client-side.
  • SaaS-friendly integration: embed document workflows inside portals, dashboards, CRMs, and customer-facing apps.
  • Framework support: use it with React, Angular, Vue, Next.js, Nuxt.js, and more.
  • Commercial flexibility: standalone and server-backed deployment options for different product needs.

🎬 Live Demo

Try ComPDF in action:

⚡ Quick Start

Requirements: Node.js latest stable, npm-compatible package manager, and a valid ComPDF web license.

1. Install

npm install @compdfkit_pdf_sdk/webviewer

2. Copy the WebViewer assets

cp -a ./node_modules/@compdfkit_pdf_sdk/webviewer/dist/. ./public/webviewer

3. Initialize the viewer

import WebViewer from '@compdfkit_pdf_sdk/webviewer';

const viewer = document.getElementById('viewer');

WebViewer.init(
  {
    path: '/webviewer',
    pdfUrl: '/webviewer/example/developer_guide_web.pdf',
    license: '<Input your license here>',
  },
  viewer,
).then((instance) => {
  const docViewer = instance.docViewer;

  docViewer.addEvent('documentloaded', () => {
    console.log('document loaded');
  });
});

Standalone deployment runs in the browser, so no backend is required for rendering PDFs.

🧩 Key Features

  • 🌐 Browser PDF Rendering
    Render PDFs with smooth navigation, thumbnails, and a ready-made document UI.
    👉 Use case: SaaS dashboards, customer portals, embedded viewers

  • ✍️ Annotations, Forms & Signatures
    Review, mark up, fill, and sign documents inside the browser.
    👉 Use case: contract workflows, onboarding, collaboration

  • 🛠️ Editing & Document Operations
    Support content editing, page workflows, and document manipulation in web apps.
    👉 Use case: online PDF editors, review platforms, content operations tools

  • 🔐 Security & Comparison
    Add secure document handling and compare PDFs in browser-based workflows.
    👉 Use case: legal review, approval systems, quality control

  • 🧱 Framework-Friendly Integration
    Use one PDF layer across React, Angular, Vue, Next.js, and other frontend stacks.
    👉 Use case: multi-team SaaS platforms and reusable frontend infrastructure

  • 🔄 Convert / OCR / Generate via ComPDF API
    Combine WebViewer with backend document processing when your product needs more than in-browser interaction.
    👉 Use case: invoice extraction, document generation, server-side automation

💡 Use Cases

  • Document Management Systems with browser-based viewing and review
  • PDF Editors embedded in SaaS products
  • Customer Portals for form filling, signatures, and secure document exchange
  • Invoice Processing UIs that preview files in browser before OCR/extraction workflows
  • No-Backend Viewer Scenarios where client-side rendering simplifies deployment

🧪 Code Snippets

Vanilla JavaScript example

import WebViewer from '@compdfkit_pdf_sdk/webviewer';

const element = document.getElementById('viewer');

WebViewer.init(
  {
    path: '/webviewer',
    pdfUrl: '/webviewer/example/developer_guide_web.pdf',
    license: '<Input your license here>',
  },
  element,
).then((instance) => {
  const docViewer = instance.docViewer;

  docViewer.addEvent('documentloaded', () => {
    console.log('ComPDFKit WebViewer loaded');
  });
});

React example

import { useEffect, useRef } from 'react';
import ComPDFKitViewer from '@compdfkit_pdf_sdk/webviewer';

export default function WebViewerContainer() {
  const containerRef = useRef(null);

  useEffect(() => {
    ComPDFKitViewer.init(
      {
        path: '/',
        pdfUrl: './example/developer_guide_web.pdf',
        license: '<Input your license here>',
      },
      containerRef.current,
    ).then((core) => {
      const docViewer = core.docViewer;

      docViewer.addEvent('documentloaded', async () => {
        console.log('document loaded');
      });
    });
  }, []);

  return (
    <div
      ref={containerRef}
      style={{ width: '100%', height: '100vh', overflow: 'hidden' }}
    />
  );
}

🔗 Documentation & Resources

ResourceLink
Official Docshttps://www.compdf.com/guides/pdf-sdk/web/overview
Viewer Guidehttps://www.compdf.com/guides/pdf-sdk/web/viewer
GitHub Exampleshttps://github.com/ComPDFKit/compdfkit-web-example-react
Demohttps://www.compdf.com/demo/webviewer

❤️ Engagement

If ComPDF helps your web product ship faster, please ⭐ Star us on GitHub to support the project.

ComPDF is a strong fit for teams that want browser rendering, customizable UI, and a clean upgrade path from PDF viewing to full document workflows.

版本与发布记录

@compdfkit_pdf_sdk/webviewer 共发布 36 个版本,首次发布于 2025/05/27;过去 12 个月发布了 9 个版本。

版本发布日期距今
3.0.0latest2026/10/2713 天前
2.9.42026/09/012 个月前
2.9.32026/07/034 个月前
2.9.22026/06/154 个月前
2.9.12026/05/155 个月前
2.8.62026/05/116 个月前

其他发布通道:rc → 2.9.0-rc.1。

关于 @compdfkit_pdf_sdk/webviewer 的常见问题

@compdfkit_pdf_sdk/webviewer 是什么?

ComPDF WebViewer is a JavaScript PDF SDK for Web apps that need PDF viewing, annotation, editing, forms, signatures, comparison, and security directly in the browser. For teams building broader document workflow products, ComPDFKit also works with

如何安装 @compdfkit_pdf_sdk/webviewer?

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

@compdfkit_pdf_sdk/webviewer 支持 TypeScript 吗?

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

@compdfkit_pdf_sdk/webviewer 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@compdfkit_pdf_sdk/webviewer 可以商用吗?

@compdfkit_pdf_sdk/webviewer 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@compdfkit_pdf_sdk/webviewer 的下载量有多少?

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

@compdfkit_pdf_sdk/webviewer 还在维护吗?

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