Quantcast
Channel: Manfaat Sehat
Viewing all articles
Browse latest Browse all 61

PDF manipulation: Crop and extract pages

$
0
0
At work we mistakenly scanned an 8.5x11 paper into an 11x17 sized PDF.  That's exactly double the size we wanted!  The left side of each page was the desired image, and the right half was blank.

The solution was to use 'pdfcrop' to adjust the margins:
shell$ pdfcrop --margins '0 0 -612 0' infile.pdf --clip  outfile-cropped.pdf

The main flag being:
--margins 'left top right bottom'

At 72DPI, removing 8.5 inches of blank space required that we remove (8.5 x 72 = 612), so -612 pixels.

The pdfcrop help info reads,
> add extra margins, unit is bp

By doing this with a negative number, pdfcrop removes the margins.  'Unit is BP' is meaningless to me and most of the web that I searched, but it turns out to mean pixels, basically.

Once we had this cropped (it looked great), we needed to cut the huge file into two smaller PDFs. pdftk, the PDF Toolkit, to the rescue!

We cut the first 50 pages for the first file:
shell$ pdftk A=outfile-cropped.pdf cat A1-50 output outfile-cropped-p1-50.pdf

and the next 85 pages for the second file:
shell$ pdftk A=outfile-cropped.pdf cat A51-130 output outfile-cropped-p51-130.pdf

Viewing all articles
Browse latest Browse all 61

Latest Images

Trending Articles



Latest Images