我需要在收据打印机(Star TSP100)上打印几行。我可以将文本写入文件并使用此行打印:
Desktop.getDesktop().print(new File("test.txt"));
问题是我这样做时的文本大小非常小。由于文件是纯文本,我不知道如何调整大小。
使此文本可读的最简单方法是什么?
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.
将 lpr 命令直接发送到打印机会产生合理的文本大小。此解决方案适用于我的情况。