#! /bin/bash ## This is an extension to the HylaFAX [TM] fax server ## ## It provides an option to receive fax transmission reports ## in pdf format; these include the first page of sent fax ## document(s); fax reports are requested as file format REPORT ## and can be combined with TIFF, PDF, PS and RAW attachments ## ## The extension also allows HylaFAX [TM] users to define a ## custom file name pattern for e-mail attachments (i.e., ## attached copies of sent and received faxes) in FaxNotify ## and FaxDispatch; see CustomFileName() for details ## ## This extension includes modified/extended versions of ## two functions - BuildAttachArgs(), ConvertFile() - ## originally released with HylaFAX (TM) and ## located in the shell script ## ## /var/spool/hylafax/bin/common-functions ## ## The original script is available from http://hylafax.org ## ## Original and modified HylaFax [TM] code has been labelled ## as such at the end of each line: # HylaFAX[, modified] ## ## Original Code / Copyright Notice: ## ## Copyright (c) 1988-1996 Sam Leffler ## Copyright (c) 1991-1996 Silicon Graphics, Inc. ## HylaFAX is a trademark of Silicon Graphics ## ## Modifications and Added Code / Copyright Notice: ## ## Copyright (c) 2015 Schellen C ## ## Original Code / License and Usage Information: ## ## Permission to use, copy, modify, distribute, and sell this software and ## its documentation for any purpose is hereby granted without fee, provided ## that (i) the above copyright notices and this permission notice appear in ## all copies of the software and related documentation, and (ii) the names of ## Sam Leffler and Silicon Graphics may not be used in any advertising or ## publicity relating to the software without the specific, prior written ## permission of Sam Leffler and Silicon Graphics. ## ## THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, ## EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY ## WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. ## ## IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR ## ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, ## OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, ## WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF ## LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE ## OF THIS SOFTWARE. ## ## Modifications and Added Code / Installation Notes ## ## Copy the extension file 'faxreport' to /var/spool/hylafax/bin ## ## Add the following line to 'notify' and 'faxrcvd', preferably right ## after the inclusion of 'common-functions' (. bin/common-functions) ## ## . bin/custom-functions ## ## Locate the following line in 'notify' and 'faxrcvd' ## ## ATTACH_ARGS="$ATTACH_ARGS "`BuildAttachArgs $ft` ## ## In 'notify' replace it with ## ## ATTACH_ARGS="$ATTACH_ARGS "`BuildAttachArgsMod $ft notify` ## ## In 'faxrcvd' replace it with: ## ## ATTACH_ARGS="$ATTACH_ARGS "`BuildAttachArgsMod $ft faxrcvd` ## ## Please notice: modifications to 'notify' and 'faxrcvd' may be ## removed in the course of HylaFAX [TM] updates ## ## The extension depends on 'ImageMagick'; see PrepareReportCreation() ## for details if you prefer not to install 'ImageMagick' ## ## Modifications and Added Code / Online Resources ## ## http://1024k.de/hylafax/fax-transmission-reports-in-pdf-format-with-hylafax.html ## http://1024k.de/hylafax/de/voip-fax-mit-asterisk-und-hylafax.html ## CollectFaxInfo ## ## Collect information about fax transmission ## while avoiding the use of HylaFAX (tm) variables ## since those may break with updates; prefer queue ## and log files for data lookups CollectFaxInfo () { # source files QFILE=$1 # from 'notify', contains job info, QFILE=./$Q/q$JOBID COMMID=$(awk -F: '$1 == "commid" {print $2}' $QFILE) # to get $COMLOG and entry in $XFERFAXLOG COMLOG=./log/c$COMMID # individual transfer log file XFERFAXLOG=./log/xferfaxlog # summary of all transfers # field counts in $XFERFAXLOG may vary due to white spaces (i.e., recipient's csi) # avoid field counts for any information after fields with potential blank spaces # variables/entries REPORTTIME=$(date +"%Y-%m-%d %H:%M:%S") # report creation time (i.e., current date/time) MODEM=$(awk -v COND=$COMMID '$4 == COND {print $5}' $XFERFAXLOG) SENDERNAME=$(grep ^LocalIdentifier.* /etc/hylafax/config.$MODEM | head -n1 | \ sed 's/.*"\(.*\).*"/\1/') # from modem config in /etc/hylafax/ (ignored if not in quotation marks) SENDERNUMBER=$(grep ^FAXNumber.* /etc/hylafax/config.$MODEM | head -n1 | \ sed 's/.*"\(.*\).*"/\1/') # 'FAXNumber' from modem config in /etc/hylafax/ CALLEDNUMBER=$(awk -F: '$1 == "number" {print $2}' $QFILE) RECIPIENTCSI=$(awk -F: '$1 == "csi" {print $2}' $QFILE) # Called subscriber identification; sent by recipient TRANSFERSTART=$(date +'%d.%m.%Y %H:%M' -d "$(awk -v COND=$COMMID '$4 == COND {print $1, $2}' $XFERFAXLOG)") TRANSFEREND=$(date +'%d.%m.%Y %H:%M' -d @"$(awk -F: '$1=="tts" {print $2}' $QFILE)") TRANSFERDURATION=$(awk -v COND=$COMMID '$4 == COND {print}' $XFERFAXLOG | \ sed -r 's/.*([0-9]{1,2}:[0-9]{2}:[0-9]{2}).*([0-9]{1,2}:[0-9]{2}:[0-9]{2}).*/\2/') PAGES=$(awk -F: '$1 == "totpages" {print $2}' $QFILE) STATUS=$(if [ $2 == 'done' ] ; then echo 'OK' ; else echo 'FEHLER'; fi) # $2=$WHY SIGNALRATE=$(awk -F: '$1 == "signalrate" {print $2}' $QFILE) RESOLUTION=$(awk -F: '$1 == "resolution" {print $2}' $QFILE | \ sed -r -e 's/[0-9]+/& lpi/' -e 's/98 lpi/normal (&)/' -e 's/196 lpi/fein (&)/' \ -e 's/391 lpi/sehr fein (&)/') # 98=normal 196=fine 391=superfine } ## PrepareReportCreation ## ## Query location of temporary directory, create copy of ## pdf_file and determine its page dimensions; set scale ## factor and xy offsets for resizing/repositioning ## ## Requires 'ImageMagick' to determine page dimensions ## ## To ascertain page dimensions without 'ImageMagick' ## get 'pdf_info.ps' from the 'Ghostscript' toolbin ## ## http://git.ghostscript.com/?p=ghostpdl.git;a=blob;f=gs/toolbin/pdf_info.ps ## ## Save 'pdf_info.ps' in /var/spool/hylafax/bin/ and use ## ## DIMENSIONS=($(gs -dNODISPLAY -q -sFile=$PDFIN -dDumpMediaSizes \ ## /var/spool/hylafax/bin/pdf_info.ps | \ ## grep MediaBox | sed "s/.*\[\(.*\)\].*/\1/")) ## PGWIDTH=${DIMENSIONS[2]};PGHEIGHT=${DIMENSIONS[3]} ## ## 'Ghostscript' is installed with HylaFAX (tm) PrepareReportCreation() { TMPDIR=$(dirname $1) PDFIN=$1 PDFOUT=${1%.*}.plus.pdf SCALE=0.6 XOFFSET=198 YOFFSET=83 # get width/height in PS points (1/72 inch) with imagemagick ('identify') # example outcome: test.pdf PDF 595×842 595×842+0+0 16bit ... # result is saved into bash array, error messages are sent to /dev/null # second entry in the array is of the form PGWIDTHxPGHEIGHT # width and height are split and saved in new array (DIMENSIONS) IDENTIFY=($(identify ${PDFIN} 2>/dev/null)) DIMENSIONS=($(echo ${IDENTIFY[2]} | sed 's/x/ /')) PGWIDTH=${DIMENSIONS[0]};PGHEIGHT=${DIMENSIONS[1]} } ## CreatePostscriptTemplate ## ## Create fax report template in postscript format ## and fill with collected fax transmission data CreatePostscriptTemplate () { echo '%! << /EndPage { 0 eq { 0 eq { %%Pages: 1 %%Page: 1 1 %%A4Dimensions: 595×842 %%BoundingBox: 0 0 0 0 newpath 235 817 moveto 360 817 lineto 360 795 lineto 235 795 lineto closepath stroke newpath 0 720 moveto 595 720 lineto stroke newpath 0 612 moveto 595 612 lineto stroke newpath 119 50 moveto 476 50 lineto 476 556 lineto 119 556 lineto closepath stroke /Courier findfont 10 scalefont setfont 262 803 moveto (SENDEBERICHT) show /Courier findfont 10 scalefont setfont 390 770 moveto (ZEIT : '$(date +"%d.%m.%Y %H:%M" -d "$REPORTTIME")') show /Courier findfont 10 scalefont setfont 390 759 moveto (NAME : '$SENDERNAME') show /Courier findfont 10 scalefont setfont 390 748 moveto (FAX/NR : '$SENDERNUMBER') show /Courier findfont 10 scalefont setfont 390 737 moveto (MODEM : '$MODEM') show /Courier findfont 10 scalefont setfont 185 695 moveto (DATUM/UHRZEIT '$TRANSFEREND') show /Courier findfont 10 scalefont setfont 185 684 moveto (FAX-ID/NAME '$RECIPIENTCSI') show /Courier findfont 10 scalefont setfont 185 673 moveto (RUFNUMMER '$CALLEDNUMBER') show /Courier findfont 10 scalefont setfont 185 662 moveto (DAUER '$TRANSFERDURATION') show /Courier findfont 10 scalefont setfont 185 651 moveto (SEITE(N) '$PAGES') show /Courier findfont 10 scalefont setfont 185 640 moveto (STATUS '$STATUS') show /Courier findfont 10 scalefont setfont 185 629 moveto (AUFLOESUNG '$RESOLUTION') show } if true } { pop false } ifelse } >> setpagedevice' > $TMPDIR/$COMMID.ps } ## CreatePDFMarks ## ## Create pdfmarks and fill with information ## in order to add PDF header info to fax report CreatePDFMarks () { echo '[ /Title (Sendebericht (Fax)) /Author (Faxserver) /Subject (Fax versendet mit Status '\'$STATUS\'') /Keywords (fax, status, report) /Creator (Faxserver) /Producer (Faxserver) /CreationDate ('$(date +%Y%m%d%H%M%S -d "$REPORTTIME")') /ModDate ('$(date +%Y%m%d%H%M%S -d "$REPORTTIME")') /DOCINFO pdfmark' > $TMPDIR/$COMMID.pdfmark } ## CreateFaxReport ## ## Create fax report and add first page of pdf_file ## to the result; replace pdf_file with fax report. ## ## Returns path/pdf_file.pdf ## ## The fax report is created by merging a rescaled copy ## of the first page of pdf_file with a dynamically ## generated postscript template and pdfmarks which ## contain the required transmission data ## ## REPORT+ has a PDF copy of the original document ## attached to the fax report ## ## Fax report files have the default file extensions ## '.report.pdf' and '.report+.pdf'. The suffixes ## can be configured in 'FaxNotify': ## ## CUSTOMSUFFIXREPORT="report" ## CUSTOMSUFFIXREPORT+="report+" ## ## Underscores will be substituted for any characters ## but literals (i.e., letters and numbers), dots, ## hyphens, underscores, and the plus sign CreateFaxReport () { CollectFaxInfo $2 $3 PrepareReportCreation $1 CreatePostscriptTemplate CreatePDFMarks gs \ -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dSAFER -dPDFSETTINGS="/printer" \ -dColorConversionStrategy=/LeaveColorUnchanged \ -dDEVICEWIDTH=$PGWIDTH -dDEVICEHEIGHT=$PGHEIGHT \ -dLastPage=1 \ -sOutputFile=- \ -c "<> setpagedevice" \ -f "$PDFIN" | gs \ -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dSAFER -dPDFSETTINGS="/printer" \ -dColorConversionStrategy=/LeaveColorUnchanged \ -dSubsetFonts=true -dEmbedAllFonts=true \ -sOutputFile="$PDFOUT" \ $TMPDIR/$COMMID.ps $TMPDIR/$COMMID.pdfmark - if [ "${4,,}" == "report+" ] ; then PDFOUTPLUS=${PDFOUT%.*}.plus.pdf gs \ -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dSAFER -dPDFSETTINGS="/printer" \ -dColorConversionStrategy=/LeaveColorUnchanged \ -dSubsetFonts=true -dEmbedAllFonts=true \ -sOutputFile="$PDFOUTPLUS" \ $PDFOUT $PDFIN $TMPDIR/$COMMID.pdfmark mv $PDFOUTPLUS $PDFOUT fi mv $PDFOUT $PDFIN echo $PDFIN } ## CustomFileName ## ## Change file names of e-mail attachments if ## a CUSTOMFILENAME pattern is defined in ## ## /etc/hylafax/FaxNotify ## /etc/hylafax/FaxDispatch ## ## By default, the original file number is preserved at ## the end of the file name; this can be turned off by ## setting $FILENUMBERING to [NO|no] in ## ## /etc/hylafax/FaxNotify ## /etc/hylafax/FaxDispatch ## ## CUSTOMFILENAME is read as string, not as variable ## ## Fax transmission time and date are substituted for ## valid time and date sequences [%] in CUSTOMFILENAME ## See 'man pages: date()' for reference ## ## Underscores will be substituted for any characters ## but literals (i.e., letters and numbers), dots, ## hyphens, and underscores ## ## e.g., fax message sent on Dec. 24th, 1970 at 09:38:59 ## original file name: doc12.ps ## CUSTOMFILENAME=%Y-%d-%m_fax_%H-%M-%S ## outcome: 1970-12-24_fax_09-38-59.12.ps ## FILENUMBERING=no ## outcome: 1970-12-24_fax_09-38-59.ps ## ## The original file names of documents on the ## server and in log entries are not altered CustomFileName () { if [ "$2" == "notify" ] || [ "$2" == "faxrcvd" ] ; then case $2 in notify) TraceLog "CustomFileName invoked by 'notify'" CUSTOMFILENAMESOURCE=/etc/hylafax/FaxNotify if [ "$4" != "" ] ; then TXTIME=$(date +"%Y-%m-%d %H:%M:%S" -d @"$(awk -F: '$1 == "tts" {print $2}' $4)") else TraceLog "Missing parameter QFILE; using current time as TXTIME" TXTIME=$(date +"%Y-%m-%d %H:%M:%S") fi NUMBERANDEXTENSION=${1##*doc} ;; faxrcvd) TraceLog "CustomFileName invoked by 'faxrcvd'" CUSTOMFILENAMESOURCE=/etc/hylafax/FaxDispatch REGEXP="^[0-9]*:[0-9]*:[0-9]* [0-9]*:[0-9]*:[0-9]*$" if [[ "$RECEIVED" =~ $REGEXP ]] ; then TXTIME=$(echo $RECEIVED | sed 's/^\([0-9]*\):\([0-9]*\):\([0-9]*\)/\1-\2-\3/') else TraceLog "Unable to retrieve transmission time; using current time as TXTIME" TXTIME=$(date +"%Y-%m-%d %H:%M:%S") fi NUMBERANDEXTENSION=$(echo $1 | sed s/^fax0*//) ;; esac CUSTOMFILENAME=$(date +"$(awk -F= '$1 == "CUSTOMFILENAME" \ {gsub (/^"/,"",$2); gsub(/"$/,"",$2); gsub(/[^a-zA-Z0-9%._-]/,"_",$2); print $2}' \ $CUSTOMFILENAMESOURCE)" -d "$TXTIME" | \ sed 's/[^a-zA-Z0-9.\_\-]/_/g') FILENUMBERING=$(awk -F= '$1 == "FILENUMBERING" \ {gsub(/^"/,"",$2); gsub(/"$/,"",$2); print $2}' $CUSTOMFILENAMESOURCE) case $3 in REPORT|report) TraceLog "Checking for custom file name suffix (pdf report)" CUSTOMSUFFIXREPORT=$(awk -F= '$1 == "CUSTOMSUFFIXREPORT" \ {gsub (/^"/,"",$2); gsub(/"$/,"",$2); gsub(/[^a-zA-Z0-9\+%._-]/,"_",$2); print "\""$2"\""}' \ /var/spool/hylafax/etc/FaxNotify) if [ "$CUSTOMSUFFIXREPORT" == "\"\"" ] ; then TraceLog "Suffix removed by user" EXTENSION=pdf elif [ "$CUSTOMSUFFIXREPORT" != "" ] ; then TraceLog "Custom suffix is applied" EXTENSION=${CUSTOMSUFFIXREPORT:1:-1}.pdf else TraceLog "No custom suffix found; default (.report.pdf) is applied" EXTENSION=report.pdf fi ;; REPORT+|report+) TraceLog "Checking for custom file name suffix (pdf report+)" CUSTOMSUFFIXREPORTPLUS=$(awk -F= '$1 == "CUSTOMSUFFIXREPORT+" \ {gsub (/^"/,"",$2); gsub(/"$/,"",$2); gsub(/[^a-zA-Z0-9\+%._-]/,"_",$2); print "\""$2"\""}' \ /var/spool/hylafax/etc/FaxNotify) if [ "$CUSTOMSUFFIXREPORTPLUS" == "\"\"" ] ; then TraceLog "Suffix removed by user" EXTENSION=pdf elif [ "$CUSTOMSUFFIXREPORTPLUS" != "" ] ; then TraceLog "Custom suffix is applied" EXTENSION=${CUSTOMSUFFIXREPORTPLUS:1:-1}.pdf else TraceLog "No custom suffix found; default (.report+.pdf) is applied" EXTENSION=report+.pdf fi ;; *) EXTENSION=${1#*.} ;; esac if [ "$CUSTOMFILENAME" != "" ] && [ "${FILENUMBERING,,}" = "no" ] ; then TraceLog "Custom file name without file number is applied" a_name=$CUSTOMFILENAME.$EXTENSION elif [ "$CUSTOMFILENAME" != "" ] ; then TraceLog "Custom file name with file number is applied" a_name=$CUSTOMFILENAME.$NUMBERANDEXTENSION else TraceLog "No custom file name pattern found; request ignored" fi else TraceLog "CustomFileName invoked by unknown script; request ignored" fi } ## BuildAttachArgsMod # HylaFAX, modified ## # HylaFAX ## Build the list of arguments to be passed on to the # HylaFAX ## Functions which do the actual mailing/attaching # HylaFAX ## # HylaFAX ## It will convert to the requested # HylaFAX ## # HylaFAX ## The result is formatted like: # HylaFAX ## "file1" "type1" "name1" "description1" \ # HylaFAX ## ["file2" "type2" "name2" "description2" [...] ] # HylaFAX ## ## Multiple documents in the same format can be received ## in a single document if FILEMERGING is set to YES ## in 'FaxNotify'; this setting applies to all file ## formats except RAW; BuildAttachArgsMod () # HylaFAX, modified { # HylaFAX FILEMERGING=$(awk -F= '$1 == "FILEMERGING" \ {gsub(/^"/,"",$2); gsub(/"$/,"",$2); print $2}' /etc/hylafax/FaxNotify) case $1 in # HylaFAX PostScript|Postscript|PS|ps) # HylaFAX a_type="application/postscript" # HylaFAX a_desc="FAX-Dokument (PostScript)" # HylaFAX, modified ;; # HylaFAX PDF|pdf) # HylaFAX a_type="application/pdf" # HylaFAX a_desc="FAX-Dokument (PDF)" # HylaFAX, modified ;; # HylaFAX REPORT|report|REPORT+|report+) a_type="application/pdf" a_desc="Fax-Report (PDF)" ;; TIFF|tiff|TIF|tif) # HylaFAX a_type="image/tiff" # HylaFAX a_desc="FAX-Dokument (TIFF)" # HylaFAX, modified ;; # HylaFAX esac # HylaFAX for i in `LocalSequence 1 $nfiles` # HylaFAX do # HylaFAX eval filename="$"files_"$i" # HylaFAX TraceLog "FILE $i: $filename" # HylaFAX if [ -f "$filename" ]; then # HylaFAX eval filetype="$"filetype_"$i" # HylaFAX if [ "$1" = "raw" ] || [ "$1" = "original" ]; then # HylaFAX a_file=$filename; # HylaFAX a_name=`basename $filename`; # HylaFAX CustomFileName $a_name $2 $1 $QFILE a_desc="FAX-Dokument" # HylaFAX, modified case "$filetype" in # HylaFAX PostScript) # HylaFAX TraceLog "Attaching $file in PostScript format" # HylaFAX a_type="application/postscript" # HylaFAX ;; # HylaFAX PDF) # HylaFAX TraceLog "Attaching $file in PDF format" # HylaFAX a_type="application/pdf" # HylaFAX ;; # HylaFAX TIFF) # HylaFAX TraceLog "Attaching $file in TIFF format" # HylaFAX a_type="image/tiff" # HylaFAX ;; # HylaFAX *) # HylaFAX TraceLog "Attaching $file in unknown[$filetype] format" # HylaFAX a_type="application/unknown" # HylaFAX ;; # HylaFAX esac # HylaFAX if [ -f "$a_file" ] ; then # HylaFAX, modified ARGS="$ARGS"" \"$a_file\" \"$a_type\" \"$a_name\" \"$a_desc\"" # HylaFAX, modified fi # HylaFAX, modified else # HylaFAX a_file=`ConvertFileMod "$filename" "$filetype" "$1" "$2"` # HylaFAX, modified a_name=`basename $a_file` # HylaFAX CustomFileName $a_name $2 $1 $QFILE if [ -f "$a_file" ] && [ "${FILEMERGING,,}" == "yes" ] ; then MERGEFILES="$MERGEFILES"" "$a_file MERGEPATH=$(dirname $a_file) MERGEFILE=$MERGEPATH/merge.tmp.$1 MERGENAME=$a_name FILECOUNT=$((FILECOUNT+1)) elif [ -f "$a_file" ] && [ "${FILEMERGING,,}" != "yes" ] ; then ARGS="$ARGS"" \"$a_file\" \"$a_type\" \"$a_name\" \"$a_desc\"" fi fi fi done # HylaFAX if [ "$MERGEFILES" != "" ] && [ "${FILEMERGING,,}" == "yes" ] && [ "$FILECOUNT" -gt 1 ] ; then touch $MERGEFILE case $1 in PostScript|Postscript|PS|ps) TraceLog "Using ghostscript to merge multiple postscript files" gs \ -q -dNOPAUSE -dBATCH -sDEVICE=pswrite -dSAFER \ -dColorConversionStrategy=/LeaveColorUnchanged \ -dSubsetFonts=true -dEmbedAllFonts=true \ -sOutputFile="$MERGEFILE" \ ${MERGEFILES:1} ARGS="$ARGS"" \"$MERGEFILE\" \"application/postscript\" \"$MERGENAME\" \"FAX Dokument (Postscript)\"" ;; PDF|pdf|REPORT|report|REPORT+|report+) TraceLog "Using ghostscript to merge multiple PDF files" gs \ -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dSAFER -dPDFSETTINGS="/printer" \ -dColorConversionStrategy=/LeaveColorUnchanged \ -dSubsetFonts=true -dEmbedAllFonts=true \ -sOutputFile="$MERGEFILE" \ ${MERGEFILES:1} if [ "${1,,}" == "pdf" ] ; then ARGS="$ARGS"" \"$MERGEFILE\" \"application/pdf\" \"$MERGENAME\" \"FAX-Dokument (PDF)\"" else ARGS="$ARGS"" \"$MERGEFILE\" \"application/pdf\" \"$MERGENAME\" \"FAX-Report (PDF)\"" fi ;; TIFF|tiff|TIF|tif) TraceLog "Using tiffcp to merge multiple TIFF files" tiffcp ${MERGEFILES:1} $MERGEFILE ARGS="$ARGS"" \"$MERGEFILE\" \"image/tiff\" \"$MERGENAME\" \"FAX-Dokument (TIFF)\"" ;; esac elif [ -f "$a_file" ] && [ "$1" != "raw" ] && [ "$1" != "original" ] ; then TraceLog "No merging of files required; returning single file" ARGS="$ARGS"" \"$a_file\" \"$a_type\" \"$a_name\" \"$a_desc\"" fi printf '%s' "$ARGS" # HylaFAX } # HylaFAX ## ConvertFileMod # HylaFAX, modified ## Convert $1 from $2 to type $3 # HylaFAX ## ## Create fax report in pdf format if invoked by 'notify' ## and if $3 indicates fax report request ## # HylaFAX ## This will (possibly) create a tempoary file # HylaFAX ## in the Private $TMPDIR area for the new file # HylaFAX ## If the original file is in the proper form, no # HylaFAX ## new file will be created # HylaFAX ## # HylaFAX ## It prints the file name of the converted # HylaFAX ## file to stdout # HylaFAX ConvertFileMod () # HylaFAX, modified { # HylaFAX case "$3" in # HylaFAX PostScript|postscript|PS|ps) # HylaFAX TraceLog "Converting $1 to Postscript" # HylaFAX case $2 in # HylaFAX PostScript|Postscript|PS|ps) # HylaFAX TraceLog "No conversion" # HylaFAX echo "$1" # HylaFAX ;; # HylaFAX PDF|pdf) # HylaFAX TraceLog "pdf2ps necessary" # HylaFAX name="`basename $1 .pdf`" # HylaFAX $PDF2PS $1 $TMPDIR/$name.ps # HylaFAX echo "$TMPDIR/$name.ps" # HylaFAX ;; # HylaFAX TIFF|tiff|TIF|tif) # HylaFAX TraceLog "tiff2ps necessary" # HylaFAX name="`basename $1 .tif`" # HylaFAX $TIFF2PS -a $1 > $TMPDIR/$name.ps # HylaFAX echo "$TMPDIR/$name.ps" # HylaFAX ;; # HylaFAX esac # HylaFAX ;; # HylaFAX PDF|pdf) # HylaFAX TraceLog "Converting $1 to PDF" # HylaFAX case $2 in # HylaFAX PostScript|Postscript|PS|ps) # HylaFAX TraceLog "Using ps2pdf" # HylaFAX name="`basename $1 .ps`" # HylaFAX $PS2PDF $1 $TMPDIR/$name.pdf >/dev/null 2>&1 # HylaFAX echo "$TMPDIR/$name.pdf" # HylaFAX ;; # HylaFAX PDF|pdf) # HylaFAX TraceLog "Nothing necessary" # HylaFAX echo "$1" # HylaFAX ;; # HylaFAX TIFF|tiff|TIF|tif) # HylaFAX TraceLog "Using tiff2pdf" # HylaFAX name="`basename $1 .tif`" # HylaFAX $TIFF2PDF -o $TMPDIR/$name.pdf $1 # HylaFAX echo "$TMPDIR/$name.pdf" # HylaFAX esac # HylaFAX ;; # HylaFAX REPORT|report|REPORT+|report+) TraceLog "Deciding whether or not to create a fax report" case $4 in notify) TraceLog "Converting $1 to PDF fax report" case $2 in PostScript|Postscript|PS|ps) TraceLog "Using ps2pdf" NAME="`basename $1 .ps`" if [ "${3,,}" == "report+" ] ; then PDFIN=$TMPDIR/$NAME$.report+.pdf else PDFIN=$TMPDIR/$NAME$.report.pdf fi $PS2PDF $1 $PDFIN >/dev/null 2>&1 TraceLog "Using CreateFaxReport" CreateFaxReport $PDFIN $QFILE $WHY $3 ;; PDF|pdf) TraceLog "Original file in pdf format" NAME="`basename $1 .pdf`" if [ "${3,,}" == "report+" ] ; then PDFIN=$TMPDIR/$NAME.report+.pdf else PDFIN=$TMPDIR/$NAME.report.pdf fi cp $1 $PDFIN TraceLog "Using CreateFaxReport" CreateFaxReport $PDFIN $QFILE $WHY $3 ;; TIFF|tiff|TIF|tif) TraceLog "Using tiff2pdf" NAME="`basename $1 .tif`" if [ "${3,,}" == "report+" ] ; then PDFIN=$TMPDIR/$NAME.report+.pdf else PDFIN=$TMPDIR/$NAME.report.pdf fi $TIFF2PDF -o $PDFIN $1 TraceLog "Using CreateFaxReport" CreateFaxReport $PDFIN $QFILE $WHY $3 ;; esac ;; *) TraceLog "Not invoked by 'notify', hence no fax report" ;; esac ;; TIFF|TIF|tif|tiff) # HylaFAX TraceLog "Converting $1 to TIFF" # HylaFAX case $2 in # HylaFAX PostScript|Postscript|PS|ps) # HylaFAX TraceLog "Using ps2fax" # HylaFAX name="`basename $1 .ps`" # HylaFAX $PS2FAX -r $resolution -o $TMPDIR/$name.tif $1 > /dev/null 2>&1 # HylaFAX, modified echo "$TMPDIR/$name.tif" # HylaFAX ;; # HylaFAX PDF|pdf) # HylaFAX TraceLog "Using pdf2fax" # HylaFAX name="`basename $1 .pdf`" # HylaFAX $PDF2FAX -r $resolution -o $TMPDIR/$name.tif $1 # HylaFAX echo "$TMPDIR/$name.tif" # HylaFAX ;; # HylaFAX TIFF|tiff|TIF|tif) # HylaFAX TraceLog "Nothing neccessary" # HylaFAX echo "$1" # HylaFAX ;; # HylaFAX esac # HylaFAX ;; # HylaFAX *) # HylaFAX TraceLog "Ignoring $1 to \"$3\"" # HylaFAX ;; # HylaFAX esac # HylaFAX } # HylaFAX