To give an idea of how it compares with PDFcrop, I had cause to crop a quite fancy PDF recently. The order of the trims should be left, bottom, right, top, as per \includegraphics from graphicx. This will output a file called input-cropped.pdf. To crop a PDF, the command you need is something like this: pdfjam -keepinfo -trim "10mm 15mm 10mm 15mm" -clip true -suffix "cropped" input.pdf For help on how to use it, I recommend the regular help screen: pdfjam -helpĪs the man page is sparse and the Web page concentrates on examples. When I can't do something with pdftk, the next place I turn is PDFjam, which is a command-line wrapper for the pdfpages LaTeX package (hence you also need that and a TeX distro installed). I have no idea though, how the Ghostscript solution compares to pdfcrop in terms of quality and correctness. For example, here I determine the minimum coordinates for x/y (the values in the upper left corner):Īnd finally, I run the script pdf_crop_by_coordinates.sh test.pdf 45 429 38 419 producing a test_cropped.pdf which looks like that: In order to determine the coordinates for cropping, I use gv, which prints the coordinates of the mouse cursor using the same units as Ghostscript. I have written a small script to simplify the process (inspired by this answer): #!/bin/bashĮcho " - all coordinates are absolute no calculation of width/height necessary"Įcho " - use 'gv' to determine the coordinates" You can also crop PDF files simply using Ghostscript. If you want margins or other things, you can of course just open the script and add arguments after pdfcrop. And new, zero-margin cropped version of all pdfs with suffix -crop will now be printed in the folder. Run the script by double clicking it and choosing Run in Terminal. Then right click the file, go to Properties > Permissions and check the field Allow executing file as program. Open it with a text editor and insert the following: #!/bin/bash It is however easy to write a script that will crop all pdfs in the folder the script is located in.Ĭreate a new empty file, and call it something.sh. Unfortunately, pdfcrop cannot crop multiple files at the time. I find this very handy when including pdf illustrations in documents. If you run only the command pdfcrop input, it will output a file titled input-crop.pdf with zero margins. For example, pdfcrop -margins '-50 -50 -50 -50' input.pdf output.pdfĬrops 50 pts from the left, top, right, bottom (in this order). To actually crop something away, use negative values in the argument for crop. If you wish to crop a pdf with left, top, right and bottom margins of 5, 10, 20, and 30 pt (points), then run pdfcrop -margins '5 10 20 30' input.pdf output.pdf I would suggest you take a look at PDFcrop.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |