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}
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}