Sending lpr commands directly to the printer results in a reasonable text size. This solution works for my situation.
Java - Printing to a receipt printer
Question
I need to print a few lines to a receipt printer (Star TSP100). I can write the text to a file and use this line to print:
Desktop.getDesktop().print(new File("test.txt"));
The problem is that the text size when I do this is very tiny. Since the file is plain text, I don't know how to adjust the size.
What's the easiest way to make this text readable?
La solution 2
Autres conseils
Just change your TXT
file to an RTF
(Rich Text Format) file! java.io.File
can read a lot of different types!
But... if you want to have full control over what you print, draw everything to a Graphics2D
object, then print that. There's a nice tutorial on how to do that here.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow