1) /etc/hylafax/hyla.conf

add the following line:
MIMEConverters: /usr/local/faxscripts/

2) place filter.pl script at /usr/local/faxscripts/

<________ /usr/local/faxscripts/filter.pl _______>

#!/usr/bin/perl
# Read from the standard input
@text=<STDIN>;
$size=@text;

# Count the number of "showpage"
$count=0;
for($i=0;$i<=$size;$i++){if($text[$i] =~ /showpage/){$count++;}}

# Discard the last line that contain "showpage"
$num=1;
for($i=0;$i<=$size;$i++){
        if($text[$i] =~ /showpage/){
                if($num!=$count){$num++;}
                else{$text[$i]=~s/showpage//g;}
        }

                print $text[$i];
}

<________ end  _______>

3) Create /usr/local/faxscripts/application/pdf

<________ /usr/local/faxscripts/application/pdf ____________>

#!/bin/bash
/bin/echo " "
/bin/echo "showpage"
/usr/bin/gs -q -sPAPERSIZE=a4 -dBATCH -dNOPAUSE -r600x800 \
-sDEVICE=pswrite -sOutputFile=- $1 | /usr/local/faxscripts/filter.pl

<________ end  _______>

4) Restart hylafax and test.


Credit to:

  Robert McIntosh, Ben Hammer, Chris Manness, and Aaron Newsome