Skip to content
Guides

Flatten PDF

This sample shows how to create a copy of Flattened.

javascript
// Import the JS file of ComPDFKit Web Demo.
import ComPDFKitViewer from "/@compdfkit/webviewer";

const viewer = document.getElementById('webviewer');
ComPDFKitViewer.init({
  pdfUrl: 'Your PDF Url',
  license: 'Input your license here'
}, viewer)
.then((core) => {
  const docViewer = core.docViewer;
  docViewer.addEvent('documentloaded', () => {
    console.log('ComPDFKit Web Demo loaded');

    // Sample: Flatten
    if (docViewer.flattenPdfDownload()) {
      console.log('Flatten done.');
    } else {
      console.log('Flatten failed.');
    }
  })
})