Did you find this guide helpful?
Some test text!
Web / Guides / Remove content
Make sure you have Full API enabled in WebViewer.
To remove all images from a document page.
WebViewer({ fullAPI: true })
.then(instance => {
const { PDFNet } = instance.Core;
await PDFNet.initialize();
const doc = await PDFNet.PDFDoc.createFromURL(filename);
const page = await doc.getPage(1);
const writer = await PDFNet.ElementWriter.create();
const reader = await PDFNet.ElementReader.create();
reader.beginOnPage(page);
writer.beginOnPage(page, PDFNet.ElementWriter.WriteMode.e_replacement, false);
for (let element = await reader.next(); element !== null; element = await reader.next())
{
const elementType = await element.getType();
switch (elementType)
{
case PDFNet.Element.Type.e_image:
case PDFNet.Element.Type.e_inline_image:
// remove all images by skipping them
break;
default:
writer.writeElement(element);
break;
}
}
writer.end();
reader.end();
})
PDF Editor (Programmatic)
Full code sample which strips all images from the page and changes text color to blue.
Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales