[PLUG] shell script to bundle postscript files into pdf with bookmarks

Galen Seitz galens at seitzassoc.com
Thu Feb 8 01:47:24 UTC 2007


Thanks the help today.  Here's what I was working on.  This
script processes data files, generates postscript plots,
and bundles them into a pdf with bookmarks.  I thought it
might be useful to someone as an example of generating a pdf
with bookmarks.  As you can see, I'm not trying to get hired
for my scripting skills, but it does work.

galen


#!/bin/sh

bookmarks=pdfmarks
output=all.pdf

cat > $bookmarks << 'EOF'
[ /Title (Document title)
  /Author (Author name)
  /Subject (Subject description)
  /Keywords (comma, separated, keywords)
  /ModDate (D:20061204092842)
  /Creator (hand written or application name)
  /DOCINFO pdfmark
EOF

count=0

for i in $(ls -v data*.txt)
do 
  count=`expr $count + 1`
  echo $i
  my_application < $i > input.dat
  gnuplot write_ps plot
  base=`basename $i .txt`
  mv output.ps ${base}.ps
  ps_files="$ps_files ${base}.ps"
  echo "[/Page $count /View [/XYZ 0 0 0] /Title ($base) /OUT pdfmark" >> $bookmarks
done

echo '[ /PageMode /UseOutlines /DOCVIEW pdfmark' >> $bookmarks

gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=$output \
	$ps_files $bookmarks




More information about the PLUG mailing list