views:

749

answers:

4

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)?

A: 

JPS lets you print to file so you just need to print to file on a PCL printer.

mark stephens
A: 

print-to-file seems to be the right approach here.

fnCzar
+1  A: 

We have a very similar process. What we do is we have a pcl file and a control file (a text file with the rightfax instructions in it). We concatenate these two files using java NIO and send it across to the rightfax print queue. We basically create a new file and write the above two into the new file using the transferFrom() method in the channel which is got by stream.getChannel(). We put control instructions at the top not at the bottom as you have mentioned? may be you misstated it - I think Rightfax needs it at the top. I have to admit I have not tried to send it at the bottom. May be it will work just dont know.

OpenSource
I didn't mean to indicate that the commands went at the bottom - I haven't tried this.
Khandelwal
+2  A: 

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.

Douglas Anderson
Just to ensure I understand correctly: With the embedded code file, the PCL file that's attached would have to be in a location accessible by the RightFax server, correct? If this is not possible, then the only option would be to send the PCL file with the embedded codes via the HPFAX queue.
Khandelwal
It needs to be accessible, it doens't; however, need to be PCL. It can be PDF or any other type that RightFax supports for input (TIF, JPG, Word etc.). If you cannot write the file to the server, you can access it via a share that RightFax has access to. As 'OpenSource' indicates you can also send this data at the top of the file, I beleive the correct term is 'false first page'. We don't do this with Embedded Codes but have done something similar with Postscript, PCL, and PDF. I will add this to my 'answer'
Douglas Anderson
Meant to say: We don't do this with Embedded Codes but have done something similar FCL with Postscript, PCL, and PDF documents
Douglas Anderson