1

I use a command-line tool (k2pdfopt) to process some PDFs, and I need to properly crop these PDFs by supplying margins in inches in the format left,top,right,bottom. I need a software with which I can quickly and easily select an area and get its margins.

I prefer a crossplatform tool, but otherwise feel free to suggest a tool for any OS but Windows. (I use both macOS and Linux.)

Adobe Acrobat's cropping feature does give me the margins, but it is very slow and it gives the margins separately like this which is hard to reformat into left,top,right,bottom: enter image description here

3 Answers 3

2

The tool pdfCropMargins will (partial list):

  • Automatically detects the margins and can crop a given percentage of them.
  • Can crop all the pages to the same size to give a uniform appearance (such as in two-up).
  • Works on Linux, Windows, Cygwin, and OS X/Darwin.
  • ...
  • Renders and analyzes page images to find the bounding boxes, which allows it to deal with noisy scanned PDFs.
  • ...
  • Can crop pages uniformly based on the nth smallest crop values, which helps with noisy images or documents where a few pages have unwanted markings in their margins.

Another suggestion is: Coherent PDF which can output:

cpdf -page-info file.pdf

Page 1:
MediaBox: 0.000000 0.000000 768.000000 1366.000000
CropBox:
Bleedbox: 0.000000 0.000000 768.000000 1366.000000
TrimBox: 0.000000 0.000000 768.000000 1366.000000
ArtBox: 0.000000 0.000000 768.000000 1366.000000
Rotation: 0
Page 2:
MediaBox: 0.000000 0.000000 768.000000 1366.000000
CropBox:
BleedBox: 0.000000 0.000000 768.000000 1366.000000
Trimbox: 0.000000 0.000000 768.000000 1366.000000
ArtBox: 0.000000 0.000000 768.000000 1366.000000
Rotation: 0

Which you could parse with a script, and then:

cpdf -crop "20mm 20mm 300mm 300mm" in.pdf -o out.pdf

There is also a recommendation to use this workflow with Acrobat Pro (which I presume you know, so just a link).

1

If you use the screen capture feature command-shift-4 the cursor is turned into cross-hairs and displays the coordinates of the screen. So moving the cursor to the top left corner yields 0-0. You can move the cursor wherever you want and determine distances by a calculating what you want.

0

If you type the key combination of shift+command+4. This combination will turn the cursor into crosshairs with the x,y pixel values written on the cursor. The return key will do a screenshot so type the Escape key to end and return the cursor to normal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.