Command line: crop PDF to paper size (Fedora)

pdfscripting

Tools like pdfcrop (from texlive) are great but they seem to be too focused on removing margins/white space. I'm trying to crop a set of letter pages (8.5×11 inches) to a size of 6×9 inches. I want this measurement to start from the top left of the page; thus the 6×9 I want is the top left 6×9 segment of the original paper, not a centered 6×9 or a 6×9 based on any margins. How can I do this via the command line? I'm on Fedora 23, so something like pdftk is unavailable.

Best Answer

You can do this with Ghostscript.

  gs \
  -sDEVICE=pdfwrite \
  -o marked.pdf \
  -c "[/CropBox [54 54 1314 810] /PAGES pdfmark" \
  -f original.pdf

The cropbox must be calculated with the resolution of your PDF, reference is the bottom left corner. See also this QA.

Related Question