5

Background

I am currently using PDFcrop to trim away unwanted margins of a multipage PDF file generated by my laptop's Print to PDF facility.

The problem is, PDFcrop is -very- slow. For a 15 page document, it takes me 17 minutes to process using the following syntax.

pdfcrop --margins "-1 0 -1 -2" Raw.pdf Cropped.pdf &> /dev/null

Needless to say this is unacceptable in light of the fact that I will be doing a similar procedure on PDF files generated in the exact same fashion that will be in excess of 150 pages long. I do not relish the thought of leaving my computer running and unattended overnight.

I have given thought to using PDFjam to crop pages instead, but it does not work as expected. I used the following command, and it unsuccessfully cropped a single page from my PDF.

pdfjam --keepinfo --trim "54 82 60 54" --clip true --suffix "cropped" page1.pdf

As illustrated in the above command, the unwanted 'margin' around each page is 54px on the left and top margins, 60px on the right margin, and 82 px on the bottom margin. If expressed as mm instead, these would equate to 19mm 28.9mm 21.2mm 19mm.

Request

Is there a way to get PDFcrop to not attempt to calculate the unwanted white space (to which my adjustments refine to the wanted cropping effect), as the margins to be deleted in each page is identical? Or a way to get PDFjam to appropriately crop the margins without cropping the content (my exercises in this regard result in certain margins that are unremovable)?

I am not able to decompress and compress the PDF in question to edit it in a text editor, as doing so locks up my computer (and manually editing multiple pages is a pain in any case, even if my computer didn't lock up in response to loading even an uncompressed PDF file as a text file), so manually editing the margins is not possible for me.

Note: Asked in Stack Overflow and was told to ask here as well. Original post (a copy of this) can be found at the following link - https://stackoverflow.com/questions/34935258/quicker-alternative-to-pdfcrop

  • Operating System: Linux (XUbuntu 13.10)
  • Budget: Zero (Using free applications, hence pdfcrop and pdfjam and nothing using official adobe)
  • Featureset: Command-line usage as I'm using the command in question within the framework of a bash script to put together and optimize the multipage PDF.
  • At the moment I'm skipping the PDFcrop phase entirely to get draft copies of the living document as I am writing it into a readable form. Every so often I reintroduce that phase, and sit around for over an hour...is there anyone out there who knows a way to remove a fixed amount of white space more efficiently? – Aren Feb 4 '16 at 19:58
  • If writing a program yourself is an option, you can probably implement this using itext in Java, playing around with the page MediaBox and/or TrimBox will probably be enough, and since you will not parse the page content and the rest of the file structure will remain the same it should work fast. – yms Feb 8 '16 at 14:54
0

Looks like you definitely should look into Coherent PDF, an open-source, cross-platform, swiss-army-knife, command-line PDF manipulation utility. This allows you to, for example:

  • Merge PDF files together, or split them apart
  • Encrypt and decrypt
  • Scale, crop and rotate pages
  • Read and set document info and metadata
  • Copy, add or remove bookmarks
  • Stamp logos, text, dates, page numbers
  • Add or remove attachments
  • Losslessly compress PDF files
  • If you'd accept GUI programs as well instead of just CLI programs, then the "FREE PDF SOFTWARE" section over at willus.com/k2pdfopt/pdf_conversion.shtml has some great pointers. – 0x01 Mar 15 '18 at 22:16
  • K2pdfopt can be used from.the command line and is great for triming (croping ) and fast – Junme Sep 17 '18 at 0:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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