Removing images from PDF page in Android

To remove all images from a document page.

1PDFDoc doc = new PDFDoc(filename);
2Page page = doc.getPage(1);
3
4ElementWriter writer = new ElementWriter();
5ElementReader reader = new ElementReader();
6reader.begin(page);
7writer.begin(page, ElementWriter.e_replacement, false);
8
9Element element;
10while ((element = reader.next()) != null)
11{
12 switch (element.getType())
13 {
14 case Element.e_image:
15 case Element.e_inline_image:
16 // remove all images by skipping them
17 break;
18 default:
19 writer.writeElement(element);
20 break;
21 }
22}
23
24writer.end();
25reader.end();

PDF Editor (Programmatic)
Full code sample which strips all images from the page and changes text color to blue.

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales