使用方法
- 复制安装命令,在自己的智能体环境安装前先检查源码包。
- 从原始文档核对所需工具、凭据和支持的宿主。
- 说明输入材料与期望交付物,并对照来源检查输出。
npx skills add https://github.com/yushulx/dynamsoft-sdk-skill --skill document-viewer开始前需了解
- 安装不包含模型订阅、API 额度或访问文件的权限。
- 仓库星数和安装量反映活跃情况,不等于独立质量或安全测试。
按源仓库内容呈现,保留标题、案例、代码、表格、链接以及原文引用的演示图片。
Dynamsoft Document Viewer (DDV)
Use this skill when the task is a document UI in the browser: render PDFs and images, page through them, annotate, rotate, reorder, delete, and export. DDV does not acquire images — for a physical scanner use web-twain; for camera capture use capture-vision-web.
Read references/integration.md for the full API reference: viewer types, annotation tools, page operations and export options.
Install
npm install dynamsoft-document-viewer@5.0.1Copy the dist assets (including the engine worker/wasm files) into the app's static directory, and serve them from the app origin.
License
DDV is licensed through Core, not through LicenseManager:
get_trial_licensewithproduct: "ddv",package: "web".status: "login_required"— a browser window opened; ask the user to finish the sign-in and call
again.
- Keep the key in configuration, show only
licenseKeyMasked, and assign it beforeinit().
import Dynamsoft from "dynamsoft-document-viewer";
Dynamsoft.DDV.Core.license = window.DYNAMSOFT_LICENSE_KEY; // never a literal
await Dynamsoft.DDV.Core.init();The order is fixed: set Core.license then await Core.init(). Calling into a viewer before init() resolves throws.
Viewer vs editViewer
| Component | Use for |
|---|---|
Dynamsoft.DDV.viewer | Read-only presentation: page navigation, zoom, search |
Dynamsoft.DDV.editViewer | Editing: annotations, page delete/rotate/reorder, forms |
const viewer = new Dynamsoft.DDV.EditViewer({
container: document.getElementById("viewer"),
group: "doc-group",
uiConfig: Dynamsoft.DDV.UIConfig.default
});
const doc = Dynamsoft.DDV.documentManager.createDocument({ name: "scan", author: "app" });
await doc.load("https://example.com/input.pdf");A Document belongs to a documentManager group; viewers render a group. Create the document once and attach it to the viewer rather than reloading the file per view.
Page and annotation operations
- Pages:
doc.getPages(),doc.insertPage(),doc.deletePages([...]),doc.movePages([...]),
doc.rotatePages([...], 90).
- Annotations:
doc.getAnnotations(), add through the edit viewer's annotation UI config, then
doc.saveAnnotations().
- Export:
doc.saveToPdf({ saveAnnotation: true }), or per-page images.
Indexes shift after a delete. Re-read the page list after any structural change instead of reusing cached indexes.
Scan → view → export
The common production flow pairs DWT and DDV:
- DWT acquires pages into its buffer.
- Each page is uploaded or converted to a blob.
- DDV loads the blobs as a document for review and annotation.
- DDV exports the final PDF.
Both SDKs take a license key: DWT assigns it to Dynamsoft.DWT.ProductKey, DDV to Dynamsoft.DDV.Core.license, and each must be set before its init() / Load() call. Request one key for the pair with get_trial_license product: "dwt-ddv"; the edition must match the runtime.
Pitfalls
- `Core.init()` before any viewer — constructing a viewer first is the most common crash.
- Assets — DDV loads wasm workers; a missing
dist/enginedirectory produces a blank viewer
with console 404s rather than a visible error.
- PDF rendering needs the worker — if the page count renders but pages are blank, check the
worker/wasm requests first.
- Dispose documents and viewers on route change; otherwise the second visit to the page shows
the previous document's state.
- Licence scope — request the key with
product: "ddv"(or"dwt-ddv"alongside Web TWAIN).
If Core.init() rejects a key that was issued for another product, request a ddv key rather than debugging the viewer.
Samples
- Document Viewer samples: https://github.com/Dynamsoft/document-viewer-samples
- Scan + view management app:
https://github.com/yushulx/web-twain-document-scan-management
- Docs: https://www.dynamsoft.com/document-viewer/docs/