views:

446

answers:

3

Our application is a client/server setup, where the client is a standalone Java application that always runs in Windows, and the server is written in C and can run on either a Windows or a Unix machine. Additionally, we use Perl for doing various reports. Generally, the way the reports work is that we generate either a text file or an xml file on the server in Perl and then send that to the client. The client then uses FOP or similar to convert the xml into a pdf. In either the case of the text file or the eventual pdf, the user select a printer via the java client and then the copied over file prints to the selected printer.

One of our "reports" is used for creating barcodes. This one is different in that it uses Perl to fetch/format some data from the database and then sends that to a C application that creates some Raw print data. This data is then sent directly to the printer (via a simple pipe in Unix or a custom application in Windows.

The problem is that this in no way respects the printer selected by the user in the Java client. Also, we are unable to show a preview in said client. Ideally, I'd like to be able convert the raw print data into a ps/pdf or similar on the server (or even on the client) and then send THAT to the printer from the client. This would allow me to show a preview as well as actually print to the selected printer.

If I can't generate a preview, even just copying over the raw data in a file to the Java client and then sending that to the printer would probably be "good enough." I've been unable to find anything that is quite what I'm trying to accomplish so any help would of course be appreciated.

Edit: The RAW data is in PCL format. I managed to reconcile the source with a PCL language reference guide.

A: 

Have you had a look at iText?

Stroboskop
I haven't, although it's not really feasible for me to bring in any new third party libraries here due to the scope of the current install base.
Morinar
A: 

You willl need to find some way of interpreting the RAW format, which most likely is some printer language like PCL or HPGL into a format you can use. This is probably best done at serverside.

A java based PCL interpreter can be found at http://openpcl.sourceforge.net/ - I have no experience with it.

Thorbjørn Ravn Andersen
A: 

I figured out a way to generate the barcodes using XSL-FO directly. This is the "correct" answer based on our architecture and trying to do anything else would have been just a dirty hack.

Morinar