Linux PDF Fun

Just a few tips and tricks for either creating or modifying pdfs under linux.

You will need to have ghostscript, imagemagick and pdftk installed.

Optimise a pdf (size/quality):

The basic command is this (lots of other options):

You can replace /screen with /default, /ebook, /printer, /prepress, for improved quality (and larger file size)

Convert an image to pdf:

Simply done with imagemagick (lots of other options):

Merging odd and even pages from multi document scans:

My scanner will only scan one side of the page, even though it has an ADF. For multiple page documents I then end up with a pdf for odd pages and a pdf for even pages. the pdftk program will happily merge the two files together, creating a single pdf with all pages in order.

Combining many pdf files to one pdf file:


Rotate a PDF

If scanning in a landscape document, you will need to rotate the page/pages in order to view in the correct orientation. So check the newly scanned pdf to see what you need to do to get it right then use the following command:

To rotate an entire pdf (single or multiple pages) anti-clockwise by 90 degrees

The page rotation setting can cause pdftk to rotate pages and documents.
Each option sets the page rotation as follows (in degrees): north: 0, east: 90, south: 180, west: 270, left: -90, right: +90, down: +180. left, right, and down make relative adjustments to a page’s rotation.

In this rotate example, an 11 page document, I needed to rotate pages 2 and 3, 6 and 7 90 degrees to the right:

Extract pages from a pdf – this example extracts pages 7 – 10 to a new pdf

Leave a Reply

Your email address will not be published. Required fields are marked *