Removing images from PDF page on Server/Desktop

To remove all images from a document page.

1$doc = new PDFDoc($filename);
2$page = $doc->GetPage(1);
3
4$writer = new ElementWriter();
5$reader = new ElementReader();
6$reader->Begin($page);
7$writer->Begin($page, ElementWriter::e_replacement, false);
8
9while (($element = $reader->Next()) != null) // Read page contents
10{
11 switch ($element->GetType())
12 {
13 case Element::e_image:
14 case Element::e_inline_image:
15 // remove all images by skipping them
16 break;
17 default:
18 $writer->WriteElement($element);
19 }
20}
21
22$writer->End();
23$reader->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