PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
This guide covers the files of the WebViewer package and how to host them.
@compdfkit_pdf_sdk/webviewer/
├── webviewer.js # ES module: import ComPDFKitViewer from "@compdfkit_pdf_sdk/webviewer"
├── webviewer.global.js # UMD: <script src="webviewer.global.js"> → window.ComPDFKitViewer
├── webviewer.d.ts # type definitions
└── dist/ # the UI, copied to webviewer/ (uiPath)
├── index.html # the page loaded in the iframe
├── assets/ # scripts and styles of the UI
├── locales/ # translation-<lng>.json
├── images/
└── lib/ # the Worker and WASM files (workerPath)
├── PDFWorker.js
├── ComPDFKit.js
├── ComPDFKit.wasm
└── DroidSansFallbackFull.ttfThe bootstrap script (webviewer.js / webviewer.global.js) is bundled into your app or loaded with a <script> tag. The dist/ folder is served as static files, as the webviewer/ folder.
| Option | Default | Points to |
|---|---|---|
path | — (required) | The folder that contains webviewer/. |
uiPath | ${path}webviewer/ | The UI folder (index.html). |
workerPath | ${uiPath}lib/ | The Worker and WASM folder. |
Relative paths are resolved against the URL of the host page.
For an app that serves its static files from public/:
cp ./node_modules/@compdfkit_pdf_sdk/webviewer/webviewer.global.js ./
cp -a ./node_modules/@compdfkit_pdf_sdk/webviewer/dist/. ./public/webviewerimport ComPDFKitViewer from "@compdfkit_pdf_sdk/webviewer";
const viewer = document.getElementById('webviewer');
ComPDFKitViewer({
path: '/',
initialDoc: 'Your PDF Url',
licenseKey: 'Input your license here'
}, viewer).then((instance) => {
console.log(instance.UI, instance.Core);
});Copy the folder again whenever you update the package, so the UI and the bootstrap script have the same version.
.wasm files with the MIME type application/wasm.file:// is not supported.cspNonce option so the styles injected by the UI are allowed.Open the page and check the browser console:
UI_LOAD_FAILED — path / uiPath does not point to the folder that contains index.html.workerPath is wrong, or the server sends .wasm with a wrong MIME type.