Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
> shell script for pdf conversion, how can i do that?
joen
post Aug 22 2006, 04:43 AM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 1
Joined: 22-August 06
Member No.: 7,034



I would like to put several commands into a shell script.
How can i reach the following:

Split a pdf file into single pages.
convert resulting pdfs to postscript.
convert resulting pses into jpgs.

It would be nice to have all files in subdirectories.
If i do
CODE
sh splitandgo.sh directory/filename.pdf

it should result in /directory/ps/, /directory/jpg/ and /directory/pdf/

The commands i tend to use are
CODE
pdftk filename.pdf burst output ./page%03d.pdf
pdftops page_0001.pdf
gs -dBATCH -dNOPAUSE -sDEVICE=jpeg -sOutputFile=filename_00.jpg -r100 filename_00.ps


Edit: I solved it!
CODE
#!/bin/sh
# A script to convert pdf to single pages pdf, ps and jpg
#
# pdftk, xpdf and ghostscript needed
###########################################################
# edit this if you like
WIDTH=200;
HEIGHT=160;
RES=100;
PREFIX=page;
PDFDIR=pdf;
PSDIR=ps;
JPGDIR=jpg;
#
###########################################################
mkdir $PDFDIR;
mkdir $PSDIR;
mkdir $JPGDIR;
pdftk $1 burst output ./$PDFDIR/$PREFIX%03d.pdf;
cd $PDFDIR;
FILES=$(ls -l | wc -l);
echo $FILES" files found";
cd ..;
COUNTER=1;
while [  $COUNTER -lt $FILES ]; do
  if test $COUNTER -ge 100
             then CURRENTPAGE=$COUNTER
             elif test $COUNTER -ge 10
               then CURRENTPAGE=0$COUNTER
             else CURRENTPAGE=00$COUNTER
           fi
           pdftops -paperw $WIDTH -paperh $HEIGHT $PDFDIR/$PREFIX$CURRENTPAGE.pdf $PSDIR/$PREFIX$CURRENTPAGE.ps;
           gs -dBATCH -dNOPAUSE -sDEVICE=jpeg -sOutputFile=$JPGDIR/$PREFIX$CURRENTPAGE.jpg -r$RES $PSDIR/$PREFIX$CURRENTPAGE.ps;
           let COUNTER=COUNTER+1;
         done;
Go to the top of the page
 
+Quote Post

Posts in this topic
- joen   shell script for pdf conversion   Aug 22 2006, 04:43 AM


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 22nd October 2017 - 12:34 PM