Search code examples
linuxpdfcrop

How to delete the hidden cropped elements from a pdf from the command line?


How can I delete the hidden cropped elements from a pdf from command line? I've tried many solutions to crop an element on a pdf page based on the coordinates, but the resulting pdf is of the same size and the extra elements are just masked instead of removed. I've found this solution, but I'm looking for a command line tool.


Solution

  • The only method I'm aware of that can do this while preserving all PDF objects inside the CropBox working on the commandline (Windows, Linux, MacOSX) is a commercial/payware software by callassoftware.

    If this is acceptable to you, please indicate that in a comment, and I'll update the answer with some more details.

    Otherwise another method is to convert the (cropped) PDF page(s) to images (f.e. to a TIFF with the help of Ghostscript), and then re-convert the image back to PDF. All previous PDF objects will be gone, and the only (graphical) "object" that's there now will be an image that's embedded on the PDF page(s).

    If this is acceptable to you, indicate this in a comment, and I'll update the answer with some more details.