środa, 22 lipca 2009

crop multipage pdf with imagemagick

I have pdf, done from network scanner, size of scan was A3 and I wanted about A4 (remove black margins). My PaperPort offers only page by page crop, and I found it time consumming (200 pages!). I found maybe painful but fast method to do it with imagemagick (with gs support (ghostscript)).
we start with:

stage 1 (left edge):
convert -density 150 document.pdf -gravity West -chop 650x0 output1.pdf

you should give a -density paramether - otherwise the output raster is 72dpi, the order is also important

stage 2 (bottom edge):
time convert -density 150 output1.pdf -gravity South -chop 0x400 output2.pdf


stage 3 (cosmetic - upper edge):
time convert -density 150 output2.pdf -chop 0x30 output3.pdf

Of course the "-gravity" settings used in the previous example is not needed and the setting defaults to a 'North-West' setting for images.

more info can be found here

0 komentarze: