On this page
Export Layers
Use the exportLayers
function to extract PDF layers or OCG (optional content group) from a document.
Incoming parameters:
- An array composed of ocg properties of the layer that needs to be exported.
- Whether to automatically download (default is false).
javascript
// 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);