Java打印罚单
我正在用这个代码在富士通fp-460上打印一张票
public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException {
Graphics2D g2 = (Graphics2D) g;
g2.translate((int)pf.getImageableY(),(int) pf.getImageableY());
g.setFont(new Font("TimesRoman", Font.PLAIN, 20));
g.drawString("Some Text", 00, 00);
g.drawString("Some Text", 00, 20);
g.drawString("Some Text", 00, 40);
g.drawString("Some Text", 00, 60);
return PAGE_EXISTS;
}
但是打印出来的纸在左右两边都有一定的边距,怎么才能打印出整页呢? 从其他地方打印时,打印机工作正常
# 1 楼答案
身体限制
这台打印机(以及大多数打印机)的最大打印宽度小于页面,因此您永远无法打印它full bleed
请看这里:https://eu.mouser.com/datasheet/2/164/fp-460-2368.pdf
相关部分:
软件限制
由于不清楚你是如何得到你的
PageFormat
,很难判断你做错了什么。也许可以检查这个答案:https://stackoverflow.com/a/10484729/461499