javapdfprinter-control-languagerightfax

PDF to PCL conversion


In my Java application, I have PDF files that I eventually need to convert to PCL and send to a RightFax server. I'll also need to embed codes in the PCL files that RightFax will read to know where to send the fax.

What's the best approach towards doing this?

Searching online, it seems like I could use Java's StreamPrintService to print the PDF files to PCL. Is this correct? Does this also mean that I must have installed on my OS a printer that can interpret PCL?

Once the PCL file is generated, I need to add the embedded codes in the file. Do I add the codes to the end of the file (by opening it in Java and writing out to it)?


Solution

  • The simplies solution, IMHO, is to drop the PDF into a folder on the RightFax server. Then create a small text file with all the instructions for who to send the document to etc. using Embedded Codes or FCL (Fax Command Language). We do this all of the time and it works great. Note: Fax Command Languate is only available if you have the Integration Module. Both Embedded Codes and FCL each have a command to attach a file(s). Once RightFax receives this text file it will process the commands and attach the PDF and fax and/or email the document. Here are two examples (one Embedded and one FCL).

    Embedded Code File:

    <TOFAXNUM:999999999>
    <TONAME:Douglas Anderson>
    <BILLINFO1:12345>
    <NOCOVER>
    <WHO:DOUG>
    <ADDDOC2: C:\pdfFiles\12345.pcl>
    

    FCL Code File:

    {{begin}}
    {{fax 999999999}}
    {{contact Douglas Anderson}}
    {{billinfo1 12346}}
    {{nocover}}
    {{attach C:\pdfFiles\12345.pcl delete}}
    {{imagetype pdf}}
    {{end}}
    

    Sending this simple text file to RightFax will prompt it to process and insert the document you specify. There are vaious ADDDOC commands and switchinges for ATTACH that tell RightFax to delete the file once it has been sent etc.

    The Embedded Code File can be sent in via the HPFAX queue and the FCL can be sent in via the Production Inbox (c:\program files\rightfax\production\inbox).

    This gives a lot of control and allows for easier troubleshooting as you still have a PDF that is viewable (due to the fact that you didn't stick text at the start of it), and you can easily output the Embedded Code or FCL files to an alternate folder for viewing and even modifying with simple tools like Notepad.


    Edit: OpenSource is correct that you can concatenate files together, I haven't done this with Embedded Codes for a long time (see example at end) but have done something similar with FCL (if you have the Ingetration Module you can do this).

    FCL with PDF or Postscript embedded in data (RightFax treats PS and PDF): {{begin}} {{fax 999999999}} {{contact Douglas Anderson}} {{billinfo1 12346}} {{nocover}} {{beginpostscript}} %PDF-1.3... ...your pdf... {{endpostscript}} {{end}}

    The PCL variant looks like this:

    {{begin}}
    {{fax 999999999}}
    {{contact Douglas Anderson}}
    {{billinfo1 12346}}
    {{nocover}}
    {{beginpcl}}
    ...your pcl data...
    {{endpcl}}
    {{end}}
    

    False first page with Embedded Codes (as per my notes from something we did a long time ago):

    <TOFAXNUM:999999999>
    <TONAME:Douglas Anderson>
    <BILLINFO1:12345>
    <NOCOVER>
    <WHO:DOUG>
    <DELETEFIRSTPAGE>
    *PCL formfeed character*
    ...your pcl data...
    

    Whatever you send will appear on the 'first page' but this will be deleted. The other option is to send this data after the Formfeed a the end of the document and use the <DELETELASTPAGE> option. This data can also appear inline with the PCL file itself and as such you may be able to send it at the start of the job without the <DELETEFIRSTPAGE> command and the formfeed splitter.