1

When I use the preview in macOS to crop a PDF file, the hidden content (outside of the cropped region) is still there. One can also notice this because the file size does not change.

I noticed that EPS figures can be directly opened (e.g. by vim) and I can then change the BoundingBox etc. After that, I can use TeXShop to covert the EPS file to a PDF file, and the file size is reduced. Can one do this directly to a PDF file? Does the PDF file also have a BoundingBox or something similar, which can be modified directly by vim?

1

2 Answers 2

1

Does the PDF file also have a BoundingBox or something similar, which can be modified directly by vim?

Yes, it has. However, PDF streams tend to be compressed. Uncompressing the PDF before might be necessary.

Also note that PDFs are arbitrarily nestable. The /BBox that you modify might not be what you think it is!

Can one do this directly to a PDF file?

I'd simply refer to mutool (or mupdf on some package managers) to first uncompress the file using mutool clean -d input_file.pdf uncompressed_file.pdf, then do my modification (vim or any text tool you want), then use mutool draw -o reduced_file.pdf uncompressed_file.pdf.

0

depending on your situation, you might not even need to crop. for example, if you just want to remove some text from the edge, you can:

# uncompress:
qpdf --stream-data=uncompress a.pdf b.pdf
# edit PDF like a text file, then compress again:
qpdf b.pdf c.pdf

https://github.com/qpdf/qpdf/releases

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .