Wednesday, November 24, 2010

Merging, extracting and squeezing of pdf files

1. Merging

It is very useful to combine multiple PDF documents into one file. This is useful especially if you accumulate many PDFs (newsletters, bills, etc.) over time.
Preparing Your system

#aptitude install gs pdftk
Now we will see one example how to combine pdf files let us assume we have 1.pdf,2.pdf,3.pdf files and now we need to cobmine this files using the following command:
#cd /home/bhutan/pdf_files
#ls
1.pdf 2.pdf 3.pdf
#gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combinedpdf.pdf -dBATCH 1.pdf 2.pdf 3.pdf

In the above command after “-sOUTPUTFILE=” type whatever name you want for the merged file (don’t forget to append .pdf to the end of the file name). Rename “1.pdf 2.pdf 3.pdf” to whatever your file names are (separate your file names with a space).
After you run the above command, a new PDF file called combinedpdf.pdf will be created with your individual files merged according to the order you list.
 .......................................................................................................

2. Extracting

(a) To extract (suppose page 24-30) use the following command:

#pdftk temp.pdf cat 20-30 output new.pdf 

(b) To extract a particular page:

#pdftk temp.pdf cat 21 25 28 output new.pdf

(c) To pdf pages - splitted jpeg files:

#convert input.pdf input.jpg

(d) Splitted jpeg - pdf pages:

#convert input.jpg input.pdf
...............................................................

3. Squeezing

#gs -sDEVICE=pdfwrite -dPDFSETTINGS=/screen -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf example.pdf




No comments:

Post a Comment