The Java [TM] platform provides a printing api you can use for printing your reports. This api has however 2 main disadvantages:

  • It can be slow and require much memory
  • If you use dot matrix printers, the printing can be very slow.

This is due to the fact that the Java platform always prints in graphic mode.

If you do not need to print graphics it make more sense to print in text mode. This will result in a light weighted and fast printing.

RTextPrinter provides an easy to use api for printing text mode reports. It will handle the communication with the printer and all printer configuration commands in a transparent manner for you.

RTextPrinter can also work integrated in RReport and RReport Visual Builder so that you can easily design your printed reports.

 

Even if you use text mode printer you will still be able to use the following features:

- Font selection (courier ...)
- Font style (bold, italic and underlined)
- Font size (characters per inch)

- Lines (vertical and horizontal) and rectangles
- Character set managing and charater value mapping
- Other: subscripts and superscripts, double wide, landscape format and interline spacing

Note that the set of available features depends on the printer (see features table in the documentation ).

 

.

Supported printer command sets:

- Epson ESCP and ESCP2 or compatible
- HP-PCL5 or compatible
- HP-PCL 3 (known also as Laset Jet Plus Emulation)

- IBM Proprinter
or compatible
- IBM PPDS

- Diablo

- Plain (no features)

... new command sets can be easily implemented

 

.

 

This is a very simple example:

FilePort port=new FilePort("\\\\MyServer\\HPLaserJ"); // name of shared printer in the network

TextPrinter printer=PrinterFactory.getPrinter("HP-PCL"); // get printer supporting HP-PCL command set

// create printing job
JobProperties job= printer.getDefaultJobProperties();
job.landscape=true;

printer.startJob(port,job);

// print BOLD text
prop=printer.getDefaultTextProperties();
prop.bold=true;
printer.printString("This must be BOLD",prop);
printer.newLine();

// print line
printer.printHorizontalLine(5,0,80); // row 5, column 0 to 80

printer.endJob();

 

The evaluation version can be downloaded here.

 

Contact us ( java4less AT confluencia.net ) if you are have any question.