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.
Sometimes the document dones't embed a font, in this case, you can import a custom font.
You should create the fonts.json, which should contain the fonts you want to import.
// fonts.json
[
{
"family": "DroidSansFallbackFull",
"filePath": "DroidSansFallbackFull.ttf"
}
]The fonts to be imported need to be placed in a folder such as /webviewer/lib/, and the created fonts.json file above also needs to be placed in this folder. Then you can init your webviewer and import the fonts in your project.
// Import the JS file of ComPDFKit Demo.
import ComPDFKitViewer from "@compdfkit_pdf_sdk/webviewer";
const viewer = document.getElementById('webviewer');
ComPDFKitViewer({
path: '/',
initialDoc: './example/Quick Start Guide for ComPDFKit Web Demo.pdf',
licenseKey: '<Input your license here>',
webFontURL: '/webviewer/lib/',
}, viewer).then((instance) => {
const { documentViewer } = instance.Core
documentViewer.addEventListener('documentLoaded', async () => {
console.log('document loaded')
})
})