Removing images from PDF page on Server/Desktop

To remove all images from a document page.

1doc = PDFDoc.new(filename)
2page = doc.GetPage(1)
3
4writer = ElementWriter.new()
5reader = ElementReader.new()
6reader.Begin(page)
7writer.Begin(page, ElementWriter::E_replacement, false)
8
9element = reader.Next() # Read page contents
10while !element.nil? do
11 type = element.GetType()
12 case type
13 when Element::E_image, Element::E_inline_image
14 # remove all images by skipping them
15 else
16 writer.WriteElement(element)
17 end
18 element = reader.Next()
19end
20
21writer.End()
22reader.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