I want to print directly using a line printer i.e. a dot matrix printer using its features of font tab carriage return and line feed from my JAVA program. I basically know how to print from JAVA. My problem is that in JAVA printing we first generate the graphic image of the page to be printed and then send it to the printer to be printed. But I am not asking my question on those lines. I want to directly send the text as a stream of characters to the printer with the applicable commands for the printer for carriage return, Line feed, tabs and font of the printer just as in the old days when graphic printers like the laser or the inkjet printer were not in use.
I shall be very grateful if someone could guide me on these points. Thanks in advance.
Additional Info
Some of the comments are suggesting simple method of printing from a JTextComponent. Here we do not have to go through the task of creating the graphical printable which is automatically handled by the the JTextComponent, but my question is how to print without creating a graphical printable. Which means that first I select the font to use from the available fonts in my printer say "courier" and then I sent 'A' to the printer and the printer prints 'A' in "courier", then when I sent 'B' to the printer the printer prints 'B' in "courier" and so in till I change the selected font in my printer. Now at the end on the line, I sent \n for linefeed which will advance the roller drum of my printer by one line and \r for carriage return which will bring my printer's printing head to the beginning of the line.
For clarification I do not want to use printable interface, as the print method of this interface basically is used to generate a graphic image using the graphics object that is being passed as parameter to the print method. After this the JVM sends this graphics object to the printer to be printed as an image. This is not what I want. I want to use the line-printer's features of font and other commands.
JTextPane
class's methodsetText("hello")
and send it to printer usingprint()
? – Sharp Edge