Sunday, July 06, 2008

Custom Fax Cover Sheets & Hylafax & AvantFax

There is nothing more difficult than making a custom cover sheet for Hylafax. Of all the programming languages I have ever glanced at, Postscript is by far the most cryptic. I spent about 6 hours the other day trying to follow the instructions on the official Hylafax tweaking page. . I designed my cover sheet in photoshop and left the fields blank. Exported it as PNG and imported it into TGIF. I used TGIF's text tool and printed as EPS at first and tried using the script to make a coversheet.



That just didn't work.

I followed the instructions on this page for manual preparation of the raw PS file for faxcover.

I spent 5 hours banging my head against the wall trying to figure out why when I replaced

(XXXX-from-company) SH


with


/from-company IS


and added the macros to the top of my PS file , nothing was working right (Fields were not replaced)



After many hours I had slipped up and accidentally left some fields in the format seen in the PS file (the format the fields were in the raw PS printoff from TGIF)

(XXXX-from-company) SH



Now why would that work? Apparently, All I needed to do was just place the fields with TGIF in that format and things would work. So I did that, tried again and everything worked perfectly. Now just to make that sheet the default cover sheet system wide as opposed to AvantFax's cover sheet. I copied the faxcover.ps file to /etc/hylafax and /var/spool/hylafax/etc and made sure their timestamps were synced (hylafax won't start otherwise).



I left the -C argument out of the sendfax command to use the system template and voila! Failure!. The resulting fax still had AvantFax's coversheet. I remembered that during installation there was a note about replacing hylafax's default coversheet. I looked into the AvantFax installer source code




(debian-install.sh from AvantFax 3.1.2)
mv $HYLADIR/bin/faxcover $HYLADIR/bin/faxcover.old
ln -s $INSTDIR/includes/faxcover.php $HYLADIR/bin/faxcover


Shocked! AvantFax actually replaces the system wide faxcover program with a CLI PHP script! Their PHP script is made to mimic faxcover (but they conveniently forgot to update the man page for faxcover). I looked into the code, and its set to use AvantFax's cover sheet in the avantfax installation directory ($INSTDIR/includes/faxcover.ps). I replaced that file and Voila, My custom coversheet was working!