#!/bin/bash  
#
# show_url: Print filter to overlay page title and URL on output page
# author:   S. Edward Hawkins III  
# date:     1999 October 20
#           
# HISTORY: 20 October 1999. Created seh3.


url=`/home/tim/src/misc/url`    # Use T.Edwards program to 
                                # grab URL from active netscape window


while read -r label; do            # Read each line of ps file from stdin
  case "$label" in

    %%Title:* )                         
        # Extract Title of page from comment field
         title=${label#*: }
        ;;

    '%%Orientation: Portrait')
        layout='portrait'
        xpos=576        # (8.5-0.5)*72 points/inch  RIGHT MARGIN
        ypos=774        # (11-0.25)*72 points/inch  TOP MARGIN
       ;;
    
    '%%Orientation: Landscape')
        layout='landscape'
        xpos=27          # 0.375 inch from left page edge (TOP MARGIN)
        ypos=756         # (11-0.5)*72 points or 0.5 inch from top edge
        ;;               # still need to compute justification (RIGHT MARGIN)

     showpage)
        case "$layout" in
        
            portrait) 
                echo gsave 0 0 translate
                echo /Times-Roman findfont 8 scalefont setfont 
                echo 36 $ypos moveto \($title\) show 
                echo %%% GET LENGTH OF URL STRING FOR RIGHT JUSTIFICATION
                echo \($url\) stringwidth pop $xpos exch sub 
                echo $ypos moveto \($url\) show grestore
                ;;

            landscape) 
                echo gsave 0 0 translate
                echo /Times-Roman findfont 8 scalefont setfont 
                echo $xpos 36 moveto 90 rotate \($title\) show -90 rotate
                echo %%% GET LENGTH OF URL STRING FOR RIGHT JUSTIFICATION
                echo \($url\) stringwidth pop $ypos exch sub $xpos 
                echo  exch moveto  90 rotate \($url\) show grestore
               ;;

        esac
        ;;

  esac

  echo $label

done




