2021年3月24日星期三

Dual Side printing with DocPrintJob (Java)

I am having two byte[], one is for front another for back. I want to print a single card, dual sided with those 2 byte arrays. My code looks like as below:-

    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);          }      }  
https://stackoverflow.com/questions/66741712/dual-side-printing-with-docprintjob-java March 22, 2021 at 03:17PM

没有评论:

发表评论