PDA

View Full Version : HOWTO: Convert .ps to PDF...a few tricks



buldir
June 3rd, 2005, 09:28 AM
If you would like to save multiple web pages (from many sources) for off-line viewing in PDF format, these simple scripts are for you. In Firefox, for example, simply click on the printer icon, select "Print To" File, name the file what you like (with a .ps extension), and hit "Print". The first script (makepdf) converts multiple .ps files in a given directory to corresponding multiple PDFs with the same name, while the second script (cat_ps2pdf) converts multiple .ps files to one PDF with a file name chosen by you. Enjoy!

makepdf

#! /bin/bash

for ps_file in *.ps; do
base=${ps_file%%.*}
gs -q -dBATCH -dAutoFilterColorImages=false -sColorImageFilter=FlateEncode -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=${base}.pdf ${ps_file}
done

cat_ps2pdf

#! /bin/bash

echo "Enter the output PDF filename (without pdf extension): "
read output_file
ps_files=`ls *.ps`
gs -q -dBATCH -dAutoFilterColorImages=false -sColorImageFilter=FlateEncode -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=${output_file}.pdf ${ps_files}

buldir
June 3rd, 2005, 10:03 AM
Here is another option for KDE users via the "kprinter" command:

http://www.granneman.com/webdev/browsers/mozillafirefoxnetscape/linuxspecific/kdeprintinginmozilla/

az
June 3rd, 2005, 02:31 PM
http://test.wiki.ubuntu.com/forum/software/cups-pdf

manishsingh4u
March 17th, 2008, 11:45 AM
Thanks. It works great.

Geekkit
June 25th, 2009, 08:03 PM
If you would like to save multiple web pages (from many sources) for off-line viewing in PDF format, these simple scripts are for you. In Firefox, for example, simply click on the printer icon, select "Print To" File, name the file what you like (with a .ps extension), and hit "Print". The first script (makepdf) converts multiple .ps files in a given directory to corresponding multiple PDFs with the same name, while the second script (cat_ps2pdf) converts multiple .ps files to one PDF with a file name chosen by you. Enjoy!

makepdf

#! /bin/bash

for ps_file in *.ps; do
base=${ps_file%%.*}
gs -q -dBATCH -dAutoFilterColorImages=false -sColorImageFilter=FlateEncode -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=${base}.pdf ${ps_file}
done

cat_ps2pdf

#! /bin/bash

echo "Enter the output PDF filename (without pdf extension): "
read output_file
ps_files=`ls *.ps`
gs -q -dBATCH -dAutoFilterColorImages=false -sColorImageFilter=FlateEncode -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=${output_file}.pdf ${ps_files}

I hope it's not too late to say thanks but THANK YOU! This is a great little script and works like a charm. :))

kingnebby
June 27th, 2009, 09:33 PM
Thanks a bunch, just what I was looking for!!!!:D