Personal tools
HylaFAX The world's most advanced open source fax server

Handbook:Advanced Server Configuration:Faxing Third-Party Document Formats

Revision as of 16:28, 28 October 2009 by Darren (talk | contribs) (Typerules - HylaFAX's document Conversion Engine)

Typerules - HylaFAX's document Conversion Engine

HylaFAX includes native support for faxing PDF, Postscript and TIFF document formats, but is easily extended to support nearly any common document format through a conversion engine know as typerules. If you hand HylaFAX some arbitrary document on the sendfax command line, the processing logic will look something like:

  1. Identify the file using its unique electronic signature (magic fingerprint) and consult HylaFAX's typerules file for a rule that matches this signature
  2. If a match is found, invoke the conversion program using the command line arguments defined there, and fax any resulting converted documents
  3. If a match is not found, report that we were unable to determine file type

An excerpt of the default typerules file from a typical HylaFAX server looks like this:

# These are the "null rules"--i.e. for matching formats handled
# directly by the server.
#offset datatype        match           result  rule
0       string          %!              ps
0       short           0x4d4d          tiff
0       short           0x4949          tiff
0       short           000732          tiff    %F/sgi2fax -%f -o %o -v %V\
                                                  -s %s %i
0       short           017436          error   packed data
0       short           017635          error   compressed data
0       short           0x0506          ps      showcase -p -f %i
0       short           0x5343          ps      showcase -p -f %i
0       short           0xf702          ps      dvips -q -o %o %i
0       string          GIF             tiff
>3      string          87a             tiff    gif2tiff -%f -v %V %i %o
>3      string          89a             error   GIF (version 89a)
0       long            0x59a66a95      tiff    ras2tiff -%f -v %V %i %o
# HylaFAX now has server-side PDF conversion, so no need for pdf2ps.
# If you have trouble or if you prefer to use pdf2ps, comment this 
# next line and uncomment the second.
0       string          %PDF            pdf
#0      string          %PDF            ps      pdf2ps %i %o
# NB: psdit is the Adobe Transcript program for converting ditroff output
0       string          x T psc         ps      psdit <%i >%o

If you need to fax a document type that is not already supported by your HylaFAX server and you can locate third-party software that will convert it to one of the native formats (pdf, postscript or tiff), simply add the appropriate rule to the typerules file and HylaFAX will begin using the new rule immediately - no need to restart anything.

For more information on how to construct these rules, please review the typerules manual page.

Example to Support MS and OpenOffice Documents

The following procedure was initially contributed by Madhawa Jayanath on the hylafax-users mailing list:

Install apps & libs

yum install
yum install poppler poppler-utils poppler-devel

Download "jodconverter"

cd /usr/src

Create "doc2ps" Script

nano /usr/sbin/doc2ps


java -jar /usr/src/jodconverter-2.2.2/lib/jodconverter-cli-2.2.2.jar -f pdf $1
pdftops -paper A4 ${1%\.*}.pdf $2
rm -f ${1%\.*}.pdf

chmod 755 /usr/sbin/doc2ps

Create a script for starting OpenOffice headless

(Please find the location of "soffice.bin" and replace the path "/usr/lib/")

nano /usr/sbin/runoffice
/usr/lib/ "-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" -norestore  nofirststartwizard -nologo -headless  &
chmod 755 /usr/sbin/runoffice

Start OpenOffice headless


Test with a M$ Doc file

Upload a doc file to /usr/src/

doc2ps /usr/src/mytest.doc /usr/src/

If this works you can see "" in /usr/src

Add M$ DOC support to hylafax

nano /etc/hylafax/typerules

add this line to the bottom of typerules------
0      short           0xd0cf          ps      doc2ps %i %o

Send M$ doc file as a FAX

sendfax -n -d 02xxxxxxx /usr/src/mytest.doc

That's it!

Powered by MediaWiki
Attribution-ShareAlike 2.5

Project hosted by iFAX Solutions