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.
Use the exportLayers function to extract PDF layers or OCG (optional content group) from a document.
Incoming parameters:
// Get layers.
const layers = await docViewer.getLayers();
// Export the first layer.
const result = await docViewer.exportLayers(layers[0].ocg); // The return value is a new PDF file data
// Export the first two layers and download them automatically.
await docViewer.exportLayers([layers[0].ocg, layers[1].ocg], true);