4

I'd like to know what practical way of constructing reports for EPSON Dot Matrix printers exists in Java. At this time, I'm having the LX300+II model to play with.

I know that there are basically two ways of using this printer:

  1. As a typewriter, outputting directly raw ASCII data to the parallel port
  2. Graphical printing, with graphical fonts and precise positioning.

How can I use both fast printing fonts(provided by 1) and precise positioning (provided by 2)?

I know this is possible to do because a couple of years ago, I got to make reports for the EPSON FX 2180 that included drivers with native printing fonts installed in Windows. This allowed to do exactly what I want here.

Now I'm using JasperReports for graphical reporting and works fine, but I do have some reports that need to be printed in dot matrix printers and fast, too. What can be an alternative for that?

Camilo Díaz Repka
  • 4,805
  • 5
  • 43
  • 68

3 Answers3

2

Would TextPrinter fit your needs?

rbrayb
  • 46,440
  • 34
  • 114
  • 174
1

If you want to print fast in dot-matrix printers, you need to do it in "plain-text" mode. The following code works for me:

try {
    // LPT1 is the printer port
    try (FileWriter out = new FileWriter("LPT1:")) {
        out.write("String1\nString2\nString3\n");
        out.flush();
    }
} catch (IOException e) {
}
Rendicahya
  • 4,205
  • 7
  • 36
  • 56
0

//java print with printer dot matrix

String bill = "your text";

InputStream br = new ByteArrayInputStream(bill.getBytes());
BufferedReader in = new BufferedReader(new InputStreamReader(br));
String line;
//if you use windows
FileWriter out = new FileWriter("////IP Printer//printer name");
//if you use linux you can try SMB:(samba)
while((line = in.readLine()) != null)
{  
    System.out.println("line"+line);
    out.write(line);
    out.write(0x0D);  CR
    out.write('\n');
    writer.println(line);
}
out.close();
in.close();
writer.close();

//it work for me...

lucky kurniawan
  • 136
  • 2
  • 8