我使用awt.print编写一个适用于网络连接的喷墨打印机的打印程序。当我在USB点阵打印机上运行程序时,它似乎不起作用。(程序可以识别打印机)任何人都可以告诉我原因。 这是一些代码:
public int print(Graphics g, PageFormat pf, int page)
throws PrinterException {
/* We have only one page, and 'page' is zero-based */
if (page > 0) return Printable.NO_SUCH_PAGE;
Graphics2D g2 = (Graphics2D) g;
g2.setPaint(Color.black);
drawPage(g2, page);
return Printable.PAGE_EXISTS;
}
public void drawPage(Graphics2D g2, int page) {
Font font1 = new Font("宋体", Font.BOLD, 14);
g2.setFont(font1);
g2.drawString(printStr1, 10.0, 10.0);
}