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

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

Revision as of 12:09, 19 August 2011 by 212.149.48.43 (talk) (Create a script for starting OpenOffice headless)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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 openoffice.org-core openoffice.org-headless openoffice.org-base openoffice.org-calc openoffice.org-writer openoffice.org-impress openoffice.org-draw openoffice.org-graphicfilter openoffice.org-pyuno openoffice.org-xsltfilter openoffice.org-math
yum install poppler poppler-utils poppler-devel

Download "jodconverter"

cd /usr/src
wget http://downloads.sourceforge.net/project/jodconverter/JODConverter/2.2.2/jodconverter-2.2.2.zip?use_mirror=biznetnetworks
unzip jodconverter-2.2.2.zip


Create "doc2ps" Script

nano /usr/bin/doc2ps

#!/bin/bash

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/bin/doc2ps

Create a script for starting OpenOffice headless

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

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

Start OpenOffice headless

runoffice

Add "/usr/sbin/runoffice" to your "/etc/rc.local" so that it starts automatically at boot time.

Test with a MS Doc file

Upload a doc file to /usr/src/

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

If this works you can see "mytest.ps" in /usr/src

Add MS DOC support to hylafax

nano /etc/hylafax/typerules


add this line to the bottom of typerules------
0		short		0xd0cf		ps	doc2ps %i %o
# Zip documents
0		long		0x504b0304	error	Zip file not supported
# Office 2007 documents
>4		long		0x14000600	ps	doc2ps %i %o

Send MS doc file as a FAX

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


That's it!


This page was last modified on 19 August 2011, at 12:09.

Powered by MediaWiki
Attribution-ShareAlike 2.5

Project hosted by iFAX Solutions