我有两个字节 [],一个用于前面,另一个用于后面。我想用那些 2 字节数组打印一张双面卡片。我的代码如下所示:-
private void print(byte[] frontSideByte, byte[] backSideByte) {
PrintService printService = getPritnerService();
DocFlavor flavor = DocFlavor.BYTE_ARRAY.PNG;
DocPrintJob job = printService.createPrintJob();
DocAttributeSet das = new HashDocAttributeSet();
das.add(Sides.DUPLEX);
das.add(new PrinterResolution(300, 300, PrinterResolution.DPI));
das.add(new MediaPrintableArea(0.0f, 0, 53.98f*2, 85.6f*2, MediaPrintableArea.MM));
das.add(findOrientation(frontSideByte));
Doc doc = new SimpleDoc(frontSideByte, flavor, das);
try {
job.print(doc, null);
} catch (Exception ex) {
System.out.println(ex);
}
}