View Single Post
Old 03-11-2010, 07:31 AM   #7
jft
Enthusiast
jft began at the beginning.
 
Posts: 43
Karma: 10
Join Date: Jan 2010
Location: Germany
Device: Kindle DXi
I wrote a small script for me that does the job for A4 landscape presentations.

One drawback with this method is that the pdfs are converted to images and then combined again to one pdf in the end. So you loose some sharpness. But for most of my presentations it is ok.

I create the background image with a black border, that prevents the kindle from cropping and than centre the original pdf pages inside that background image.

The script uses 120dpi to raster the pdfs and the resolution of the background image is chosen to fit an A4 landscape page. Adjust as you like.

Just start the script in a path with pdfs, and each of the pdf files is converted and stored in the "final" folder inside the current folder.

No guaranties. Use at your own risk. Ignore the error messages of composite.

Requirements:

- Linux
- imageMagick
- ghostscript

Code:
#/bin/sh


if  [ ! -d convert ]; then

        mkdir convert

fi

if  [ ! -d final ]; then

        mkdir final

fi

typeset -i number

number=0

for DATEI in *.pdf; do

        echo "processing $DATEI ..."

        OUTDATEI=final/${DATEI/.pdf/-resize.pdf}

        convert -bordercolor black -size 1550x996 xc:white -border 2x2 convert/back.png

        exitValue=$?

        number=0

        while (( exitValue == 0 )); do

                numberZero=`printf %03d $number`

                composite -quiet -gravity center -density 120 ${DATEI}[${number}] convert/back.png convert/output_${numberZero}.pdf

                exitValue=$?

                (( number++ ))

        done


        (( number-- ))

        gs -dNOPAUSE -sDEVICE=pdfwrite -q -sOUTPUTFILE=$OUTDATEI -dBATCH convert/output_*.pdf

        rm  convert/*

done



exit 0

Last edited by jft; 03-11-2010 at 07:46 AM.
jft is offline   Reply With Quote