Print to Fax

Discussion in 'General' started by galexander, Sep 30, 2009.

  1. galexander

    Joined:
    Nov 24, 2008
    Messages:
    15
    Likes Received:
    0
    Solution for running a network printer that, given a properly formatted document, will fax to a fax number. The user should be able to be on any operating system that supplies PostScript printer drivers.

    Since Vista makes everything a nightmare I was trying to find a replacement for WinPrintHylafax, software that lets a windows user print to a fax number using a windows printer. After failing a lot, I figured out it is actually pretty easy:

    Install cups (should be installed by default in elastix or yum install cups).

    edit /etc/cups/cupsd.conf, somewhere in it needs to be (Just cause https/secure is better):
    Code:
    SSLPort 8443
    Also under <Location /> and <Location /admin> you need:
    Code:
    Allow 192.168.0.*
    or whatever your local address range is, so you can start the printer later/view jobs, etc

    Paste this (adapted from old defunct Sambafax) into /usr/lib/cups/backend/cupsfax:
    Code:
    #!/bin/sh
    # constants
    SENDMAIL="/usr/sbin/sendmail"
    PS2ASCII="/usr/bin/ps2ascii"
    AWK="/bin/awk"
    SENDFAX="/usr/bin/sendfax"
    FAXFILE=$6
    MailTo=root@localhost # default, just in case the email address cannot be discerned
    
    # retrieve the faxnumber, email (for failures)
    # (case insensitive) "Faxed to: #*" and "From E-Mail: e@mail" are required
    FAXNUM=`${PS2ASCII} ${FAXFILE} | grep -i "FAXED *TO"|sed "s/.*[Ff][Aa][Xx][Ee][Dd] *[Tt][Oo]: *\\([0-9-]*\\).*/\\1/"|head -1|sed "s/-//g"`
    MailTo=`${PS2ASCII} ${FAXFILE} | grep -i "From *E-*Mail"|sed "s/.*[Ff][Rr][Oo][Mm] *[Ee]-*[Mm][Aa][Ii][Ll]: *\\([^@]*@[^ ]*\\).*/\\1/g"|head -1`
    
    # if faxnumber is found fax the tempfile
    # we donot check the validity of the faxnumber, let sendfax do this...
    if [ -z ${FAXNUM} ] ; then
        (echo "To: ${MailTo}"
         echo "From: The HylaFAX Samba dancer "
         echo "Subject: your facsimile request failed"
         echo ""
         echo "The faxnumber is not recognized in your fax of"
         echo `date`
         echo "The faxnumber is recognised via this text:"
         echo "   Faxed to: ddd-ddddddd"
         echo "No spaces or characters are allowed between the digits, just a -"
         echo ""
         echo "Please correct and retry"
        ) | 2>&1 ${SENDMAIL} -ffax -oi ${MailTo}
    else
       ${SENDFAX} -n -D -f ${MailTo} -d ${FAXNUM} ${FAXFILE}
    fi
    
    # end of show
    
    make it executable:
    Code:
    chmod +x /usr/lib/cups/backend/cupsfax
    restart cups:
    Code:
    /etc/init.d/cups restart
    Run this command ("faxprinter"=name you want your printer to be called):
    Code:
    lpadmin -p faxprinter -E -i /usr/lib/cups/backend/cupsfax
    So this creates a printer in cups that runs the script you just pasted into that file.

    Create the printer in windows (assuming you punched a hole for tcp 8443 on your fax server):
    New printer -> Network printer -> Printer on the internet/a network:
    URL:
    Code:
    https://192.168.0.2:8443/printers/faxprinter
    Any PostScript (PS) driver should do, such as Apple -> Apple LaserWriter 12/640 PS

    Now create whatever word document/rtf/txt doc you want, and anywhere in the contents, include:
    Code:
    Faxed to: 1-800-blahblah
    From E-Mail: youremail@address.com
    Print it to your Fax Printer in windows and it should arrive at the desired fax machine once hylafax queues and sends it.

    I probably overlooked something, let me know if this works/doesn't work for you.
     
  2. galexander

    Joined:
    Nov 24, 2008
    Messages:
    15
    Likes Received:
    0
    Little tip with vista(and newer?): if your certificate for httpd is not legit (eg it's self signed), Vista will fail to add the printer giving you some nonsensical error like it couldn't connect (even though it definitely can). Get around this by either using http:// instead of https://, or buying a certificate, or (in theory, not tested) storing your self-signed cert in vistas trusted certs area.
     
  3. speedy3k

    Joined:
    Feb 15, 2009
    Messages:
    48
    Likes Received:
    0
    this is something very close to what I've been looking for. however any thoughts on how to print to fax something like a pdf or other document that you may not be able to edit?
     
  4. galexander

    Joined:
    Nov 24, 2008
    Messages:
    15
    Likes Received:
    0
    sorry -- I don't know how that would be done.
    The best thing I could think of is if you can annotate the image and then, make the annotation ("Markup?") display, then go to print, then at the print dialog, under "Comments and Forms:" pick "Document and Markups" and your highlighted annotation should display. Then print.

    Note, by default, Adobe doesn't print the comments EVEN IF you select "Document and Markups" at print time, so you'll need this .reg file imported into the registry(assuming Adobe reader 9):
    Code:
    REGEDIT4
    [HKEY_CURRENT_USER\\Software\\Adobe\\Acrobat Reader\\9.0\\Annots\\cPrefs]
    "bprintCommentPopups"=dword:00000001
    NOW... there are still problems you'll have to work out, when I looked at the printed version of my document with its markup, via ps2ascii (as the script does), the text was all messed up but the phone number was in tact. "This is a test Fax To: 1-800-###-####" became:
    Code:
    This is a testst  FaFax x To: 1-800-###-####
    Best of luck...
     
  5. julio.vieira

    Joined:
    Sep 27, 2010
    Messages:
    2
    Likes Received:
    0
    I can fax from Notepad, but not from Microsoft Word or Excel.
    I got this error on cups logs:

    PID 16831 (/etc/cups/interfaces/fax) stopped with status 64!
    I [05/Oct/2010:16:33:21 -0300] Hint: Try setting the LogLevel to "debug" to find out more.
    E [05/Oct/2010:16:33:21 -0300] [Job 85] Job stopped due to filter errors.

    Can you help me please ?
    Tks,
    Julio
     
  6. galexander

    Joined:
    Nov 24, 2008
    Messages:
    15
    Likes Received:
    0
    Make sure ALL the font in the document is a font that ghostscript has access to. "Times" worked for me, as I recall.
     
  7. julio.vieira

    Joined:
    Sep 27, 2010
    Messages:
    2
    Likes Received:
    0
    Hi Karma, tks a lot for your reply, but it didn't work.
    I tried a lot of fonts.
    I forgot a detail: I'm using Windows 7, so, I doesn't have Apple Laserwriter printer driver.
    I used a HP PS print driver. Do you have any ideia on how to make it work ?
    Tks in advance.
     
  8. galexander

    Joined:
    Nov 24, 2008
    Messages:
    15
    Likes Received:
    0
    In Windows Vista this works: Manufacturer: Dell -> Printers: Dell 3100cn PS
    In Windows 7 this works: Manufacturer: Xerox -> Printers: Xerox Phaser 6120 PS

    I've tried others but not all other PS drivers, some worked, some didn't.

    Also of note is, when I originally created this post, "\"'s had to be escaped to show up in a [ code ] block. Apparently that's not the case anymore. Here's what it should look like:
    Code:
    #!/bin/sh
    # constants
    SENDMAIL="/usr/sbin/sendmail"
    PS2ASCII="/usr/bin/ps2ascii"
    AWK="/bin/awk"
    SENDFAX="/usr/bin/sendfax"
    FAXFILE=$6
    MailTo=root@localhost # default, just in case the email address cannot be discerned
    
    # retrieve the faxnumber, email (for failures)
    # (case insensitive) "Faxed to: #*" and "From E-Mail: e@mail" are required
    FAXNUM=`${PS2ASCII} ${FAXFILE} | grep -i "FAXED *TO"|sed "s/.*[Ff][Aa][Xx][Ee][Dd] *[Tt][Oo]: *\([0-9-]*\).*/\1/"|head -1|sed "s/-//g"`
    MailTo=`${PS2ASCII} ${FAXFILE} | grep -i "From *E-*Mail"|sed "s/.*[Ff][Rr][Oo][Mm] *[Ee]-*[Mm][Aa][Ii][Ll]: *\([^@]*@[^ ]*\).*/\1/g"|head -1`
    
    # if faxnumber is found fax the tempfile
    # we donot check the validity of the faxnumber, let sendfax do this...
    if [ -z ${FAXNUM} ] ; then
        (echo "To: ${MailTo}"
         echo "From: The HylaFAX Samba dancer "
         echo "Subject: your facsimile request failed"
         echo ""
         echo "The faxnumber is not recognized in your fax of"
         echo `date`
         echo "The faxnumber is recognised via this text:"
         echo "   Faxed to: ddd-ddddddd"
         echo "No spaces or characters are allowed between the digits, just a -"
         echo ""
         echo "Please correct and retry"
        ) | 2>&1 ${SENDMAIL} -ffax -oi ${MailTo}
    else
       ${SENDFAX} -n -D -f "MagicFax user <${MailTo}>" -d ${FAXNUM} ${FAXFILE}
    fi
    
    # end of show
    
     
  9. johnme

    Joined:
    Nov 28, 2008
    Messages:
    148
    Likes Received:
    0
    Hi

    All those are the best but i think jhylafax or yajhfc FAX should do the job.

    Jhylafax is working with 64bit windows7 too.

    In windows vista i have pdfcreator (latest version) and jhylafax.
    You can setup "pdfcreator" to automatically save a pdf file from each print job to a folder, and you can setup jhylafax to search for a file to the same location (like spooler do) and send it fax (it ask you for a number first).

    So for strange situations that yajhfc dont work, use pdfcreator with jhylafax.

    Thanks
    John
     
  10. galexander

    Joined:
    Nov 24, 2008
    Messages:
    15
    Likes Received:
    0

Share This Page