#!/bin/sh

##==============================================================================
## APPX_DISPLAY - Appx PDF Display Script for Unix         Updated: 05/21/03
##
##  This script will invoke the PDF viewer program (usually acroread) to display
##  a PDF report file.
##
##  The format of the command line is expected to be:
##
##	<script-name> [-delete] printfiles*
##
##  The -delete flag will be present on the command line if the .pdf file should
##  be deleted after the PDF viewer ends.  The -delete flag will only appear if
##  you choose to "Print On Screen", but not to "Print Hard Copy".  If you choose
##  to "Print Hard Copy", the spooler will delete the file (if appropriate).
##
##------------------------------------------------------------------------------

DELETE="No"

##
##  Make note of the -delete flag if present on the command line
##
if [ "$1" = "-delete" ]
  then
    DELETE="Yes"
    shift
fi

##
##  Try to find the viewer program - note, add your own viewers here
##
if [ ! -z "`type acroread 2>/dev/null`" ]
  then
    VIEWER=acroread
elif [ -x "/usr/local/Acrobat5/bin/acroread" ]
  then
    VIEWER=/usr/local/Acrobat5/bin/acroread
elif [ ! -z "`type xpdf 2>/dev/null`" ]
  then
    VIEWER=xpdf
elif [ -x "/Applications/Preview.app/Contents/MacOS/Preview" ]
  then
    VIEWER=open
elif type xdg-open >/dev/null 2>&1
then
    VIEWER=xdg-open
elif type evince >/dev/null 2>&1
  then
    VIEWER=evince
else
    VIEWER=""
fi

##
##  If we found a viewer, invoke it with the report file name
##
if [ ! -z "$VIEWER" ]
  then
    $VIEWER $* 2>/dev/null
fi

##
##  And delete the report file if the caller wants us to do so
#
if [ "$DELETE" = "Yes" ]
  then
    sleep 2
    rm -f $1
fi

##****************************************************************************
##  MODIFICATION HISTORY
##
##  DATE      BY    Description
##  --------  ---   ----------------------------------------------------------
##  03/14/13  PHB   BUG #2716 - Added support for evince PDF viewer
##
##****************************************************************************

