我正在尝试使用标签打印机(具体来说是 EPSON TM-T88V)来吐出 PNG 图像。
我可以让它打印得很好,除非我打印图像尺寸(220x175,72dpi 再次具体)打印的图像顶部有一堆空白,我认为这是浪费纸张。
关于如何减少纸张浪费的任何想法?我希望它只打印图像,最小的空白,然后剪纸。
这是我的代码
AttributeSet aset = new HashAttributeSet();
aset.add(new PrinterName(printerName, null));
/* locate a print service that can handle the request */
PrintService[] services = PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.PNG, aset);
if (services.length >= 1) {
/* create a print job for the chosen service */
DocPrintJob pj = services[0].createPrintJob();
DocAttributeSet das = new HashDocAttributeSet();
das.add(PrintQuality.HIGH);
das.add(MediaSizeName.ISO_A7); // I know the problem is here somewhere. This Media size seems to work best currently
try {
/*
* Create a Doc object to hold the print data.
*/
Doc doc = new SimpleDoc(imageByteIs, DocFlavor.INPUT_STREAM.PNG, das);
/* print the doc as specified */
pj.print(doc, null);
} catch (PrintException e) {
System.err.println(e);
}
}