Remove all objects except ...

Using pdfToolbox, you are able to remove all objects from a PDF document except those which are defined by one or more checks. This tutorial shows:

  1. How to remove objects in a PDF document except text and vector objects?
  2. How to remove objects in a PDF document except images?
  3. Remove all objects except invisible objects

Get started

  • Open the attached PDF (drag/drop or File>Open). The PDF document has text objects, vector objects and images.
  • Open Tools>Fixups
  • Create a new Fixup (as shown below)

In the search field search to "Remove all objects except"

  1. Select the "Remove all objects except" Fixup.
  2. Choose "All text objects".
  3. Click on the "plus" button to add a second check.
  1. Choose "All vector objects".
  2. Save the created Fixup.

    Change the Fixup name into 'Remove all objects except text and vector'

Create a second callas pdfToolbox Fixup (Remove all objects except images)

  1. Select the "Remove all objects except" Fixup.
  2. Change the check into the Fixup.

    Save the Fixup with the name "Remove all objects except images".

Moving forward

  1. Go to Fixups
  2. In the search field search to "Remove all objects except"
  3. Execute the Fixups one by one on a fresh sample PDF
In the search field search to "Remove all objects except"

The processed PDF document: Remove all objects except text and vector

The processed PDF document: Remove all objects except images

Remove all objects except invisible objects

Before removing invisible objects, let's check if there are any invisible objects in the document. SIFTER or context aware object detection technology is used here. Visibility: Object is invisible

Fixup to remove all objects except invisible objects

There are 16 invisible objects on the 2 page document. Next:

  1. Create a new Fixup
  2. Select the "Remove all objects except" Fixup
  3. Choose "Object is invisible" as the Apply to Check
  4. Click ok

Execute the Fixup and view the result

All the objects except the 16 invisible objects are removed.

Remove invisible objects

In a similar way, you can remove only the invisible objects by using the Fixup 'Remove objects' and in it the Check 'Object is invisible' (shown and attached below).