Removing images from PDF page on Server/Desktop

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.WriteMode.e_replacement, false);
8
9Element element;
10while ((element = reader.Next()) != null) // Read page contents
11{
12 switch (element.GetType())
13 {
14 case Element.Type.e_image:
15 case Element.Type.e_inline_image:
16 // remove all images by skipping them
17 continue;
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. Code sample is available in C++, C#, Java, Python, Go, PHP, Ruby & VB.

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales