Posted By

iblis on 08/27/09


Tagged

pdf batch crop


Versions (?)

Split (crop) double page PDFs in two


 / Published in: Perl
 

Each page is split vertically in two pages. Crop and media views are set accordingly. Text layer should be preserved. Takes a path to a PDF file as argument and produces a cropped PDF in the same location.

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: roninxyz on March 17, 2010

I have spent the last few hours learning about Perl and scripting on my Mac to be able to run this script, and I have to say that I was extremely skeptical that I'd be able to figure out anything as an almost complete newbie. Fortunately it didn't take long before I realized that PDF::API2 was a module, which sent me scrambling to figure out how to install those. But, with good instruction on the 'net, I've got this thing up and running. What a great experience and so useful! Thank you for this!

Posted By: iblis on June 28, 2010

You're welcome. I should have indeed made it clear that one needs PDF::API2...

On the Mac, you can also crop left and then right pages with Preview and re-assemble them with this script

Posted By: martienne on October 24, 2010

It works nicely for smaller files... but it doesn't seem to work on larger files, for example one with 24 pages didn't work but one with 4 pages worked. The pages all come out blank for the bigger files.
Any idea?

Posted By: iblis on November 9, 2010

@martienne I used the script on large files (300+ pages) without any problem (the only issue is increase in size). What platform are you running Perl on? Where do your PDFs come from (scan, OCRed scan...)? Do they already have the crop box set?

Posted By: andreapisac on July 22, 2011

Hi there,

I would really like to try this code. Someone on the Adobe Forum posted a step to step guide for total beginners (like myself) on how to install Perl Modules (for Mac users). I followed that and it worked fine with no problems. Then they said to fire the script (meaning this one) in order to get this great feature, but this was assuming people knew how to fire scripts. Can someone be so kind to explain to a beginner what to do once I have installed PDF::API2. Thanks a million! Andrea

Posted By: jlhkrans on December 10, 2011

Thank you very much.

If you have done some left and right cropping in the PDF before, you should change the lines 14 and 21 to: 14. $cropdata[2] = ($cropdata[2] + $cropdata[0]) / 2; 21. $cropdata[0] = ($cropdata[2] + $cropdata[0]) / 2;

You need to login to post a comment.