Skip to content

PDF Generation Template Editor

Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.

View on GitHub

Deployment ​

This guide covers the files of the WebViewer package and how to host them.

Package layout ​

@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.ttf

The 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.

Paths ​

OptionDefaultPoints 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.

Release layout ​

For an app that serves its static files from public/:

bash
cp ./node_modules/@compdfkit_pdf_sdk/webviewer/webviewer.global.js ./
cp -a ./node_modules/@compdfkit_pdf_sdk/webviewer/dist/. ./public/webviewer
javascript
import 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.

Hosting ​

  • Serve .wasm files with the MIME type application/wasm.
  • Serve the files over HTTP(S); file:// is not supported.
  • With a Content Security Policy, pass the nonce in the cspNonce option so the styles injected by the UI are allowed.

Testing the deployment ​

Open the page and check the browser console:

  • UI_LOAD_FAILED — path / uiPath does not point to the folder that contains index.html.
  • Worker or WASM errors — workerPath is wrong, or the server sends .wasm with a wrong MIME type.