For the complete documentation index, see llms.txt. This page is also available as Markdown.

Removing images from PDF page on Server/Desktop

To remove all images from a document page.

PDFDoc doc = new PDFDoc(filename)
Page page = doc.GetPage(1);

ElementWriter writer = new ElementWriter();
ElementReader reader = new ElementReader();
reader.Begin(page);
writer.Begin(page, ElementWriter.WriteMode.e_replacement, false);

Element element;
while ((element = reader.Next()) != null) // Read page contents
{
    switch (element.GetType())
    {
        case Element.Type.e_image:
        case Element.Type.e_inline_image:
            // remove all images by skipping them
            continue;
        default:
            writer.WriteElement(element);
            break;
    }
}

writer.End();
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.

Last updated

Was this helpful?