1async function main() {
2 const doc = await PDFNet.PDFDoc.createFromURL(filename);
3 const page = await doc.getPage(1);
4
5 const writer = await PDFNet.ElementWriter.create();
6 const reader = await PDFNet.ElementReader.create();
7 reader.beginOnPage(page);
8 writer.beginOnPage(page, PDFNet.ElementWriter.WriteMode.e_replacement, false);
9
10 for (let element = await reader.next(); element !== null; element = await reader.next())
11 {
12 const elementType = await element.getType();
13 switch (elementType)
14 {
15 case PDFNet.Element.Type.e_image:
16 case PDFNet.Element.Type.e_inline_image:
17 // remove all images by skipping them
18 break;
19 default:
20 writer.writeElement(element);
21 break;
22 }
23 }
24
25 writer.end();
26 reader.end();
27}
28PDFNet.runWithCleanup(main);