I usually use pdfcrop
to remove white margins of pdf illustrations in LaTeX
documents. Using it by command line:
pdfcrop myfigure.pdf
it removes all margins but to avoid me to resize the figure (if it has left and right white margins) I need a way to remove only top and bottom margins. I mean someting like
pdfcrop --margins '- 0 - 0' input.pdf
(where the -
should be a way to make pdf crop keep the original margin) to set top and bottom margins to 0
keeping original left and right margins.
Perhaps, if there is a tool to measure the white margins of a (single page) .pdf
file, I could write a script to achieve my purpose.
Best Answer
pdfcrop
reports the bounding boxes if option--verbose
is given, e.g.:It reports:
In this case, the left margin is 133. The right margin can be calculated via the width. The size of the PDF file is reported by
pdfinfo
(assuming the pages have all the same size), e.g.:It reports:
Then the missing values for
--margins
can be calculated and added:Alternatively the bounding box option can be used: