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.
To get started, you'll need:
npm create svelte@latest compdfkit-appDuring the setup process, Next.js will prompt you with a series of questions, allowing you to customize your project.For this example, we use: Which Svelte app template? - Skeleton project Add type checking with TypeScript? - Yes, using TypeScript syntax
cd compdfkit-appnpm installnpm i @compdfkit_pdf_sdk/webviewer --savenode_modules/@compdfkit_pdf_sdk/webviewer/dist.cp -a ./node_modules/@compdfkit_pdf_sdk/webviewer/dist/. ./static/webviewerAdd the PDF document you want to display to the static/webviewer/example directory. You can use our demo document as an example.
Add a component wrapper for the ComPDFKit library and save it as src/routes/+page.svelte:
<script>
import { onMount } from 'svelte';
// @ts-ignore
import WebViewer from '@compdfkit_pdf_sdk/webviewer';
/**
* @type {HTMLDivElement}
*/
let container;
let docViewer;
onMount(async () => {
await WebViewer.init({
pdfUrl: './example/developer_guide_web.pdf',
license: '<Input your license here>'
}, container).then((/** @type {{ docViewer: any; }} */ instance) => {
docViewer = instance.docViewer;
docViewer.addEvent('documentloaded', () => {
console.log('document loaded');
});
});
});
</script>
<body>
<div bind:this={container} style="height: 100vh; width: 100%; overflow: hidden;" />
</body>src/routes/+layout.js file and add the contents:export const ssr = false;npm run dev