2010-12-16

PDF Hacking

Adobe Reader X is the latest and very improved version of Acrobat's PDF Reader. The most significant changes for me were in the browser integration with Firefox. It is so much better now. The user interface is also leaner.

For me, the PDF Reading choice is settled, but for small PDF adjustments, like joining files or rotating pages, Adobe Acrobat is an expensive option.

If you are comfortable with the command prompt, there is a free and powerful option: PDF Toolkit. It is based on the iText library explained in the Manning book iText in Action.

To install pdftk, go to the web page and download the package for your operating system. For Windows, download the zip file and unzip it to C:\Program Files\pdftk.

Next, go to Start Menu, right-click on Computer, select Properties, and choose "Advanced system settings" from the left sidebar. Next press "Environment variables" button.
Create an environment variable called PDFTK_HOME and set it to pdftk folder path.
Next, add %PDFTK_HOME%\bin to the PATH variable. You can now open new command prompts and type the following command to read the help: pdftk -h

Here are a few useful examples (there are more described in the help output):

:: To concatenate xpto.pdf and xpty.pdf and output result to xpt.pdf
C:\Users\Me> pdftk xpto.pdf xpty.pdf cat output xpt.pdf

:: To rotate xpt.pdf from page 1 to end 90 degrees counter-clockwise and output to xpt-rotated.pdf
C:\Users\Me> pdftk xpt.pdf cat 1-endL output xpt-rotated.pdf

The page rotation setting can cause pdftk to rotate pages and documents. Each option sets the page rotation as follows (in degrees):
N: 0, E: 90, S: 180, W: 270, L: -90, R: +90, D: +180.
L, R, and D make relative adjustments to a page’s rotation.

No comments: