2
我使用awt.print編寫一個適用於網絡連接的噴墨打印機的打印程序。當我在USB點陣式打印機上運行程序時,它似乎不起作用(程序可以識別打印機)任何人都可以告訴我爲什麼。 下面是一些codesnip:帶點陣打印機的Java awt.print
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);
}