Ubuntu : Script to format your PDF before printing

Hi,

Following a script which receive the PDF filename and format it to print in Ubuntu. First it crop the empty space around the page, cutting the margins (pdfcrop). Then it put two pages side by side (pdfnup) and rotate it (pdftk) to allows to print from console (lpr). When it finishes is generated a file name ready_<file_name>.pdf

It requires the following packages:

sudo apt-get intall -y pdfcrop
sudo apt-get intall -y pdfjam
sudo apt-get intall -y pdftk

### pdf2print.sh ###

#! /bin/bash
FILE=$(echo $1 | sed ‘s/.pdf//’)
echo “pdfcrop –margins 12 $FILE.pdf”
pdfcrop “$FILE.pdf”
echo “pdfnup $FILE-crop.pdf –nup 2×1”
pdfnup $FILE-crop.pdf –nup 2×1
echo “pdftk $FILE-crop-2×1.pdf cat 1-endE output ready_$FILE.pdf”
pdftk $FILE-crop-2×1.pdf cat 1-endE output ready_$FILE.pdf
rm $FILE-crop.pdf $FILE-crop-2×1.pdf

See ya

One Response to Ubuntu : Script to format your PDF before printing

  1. eduardomucelli says:

    I will post something like that but it’s called pagecrunch, a tk-based application that deals with a psutils backend.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: