[英]Print duplex in Java
How can I print duplex in java!? 如何在Java中打印双面打印!
Here's my code, but it didn't work - it only works in microsoft word (so the printer can do it) 这是我的代码,但是没有用-它只能在Microsoft Word中工作(因此打印机可以做到)
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
pras.add(new Copies(2));
pras.add(Sides.DUPLEX);
PrinterJob pj = PrinterJob.getPrinterJob();
PageFormat pf = pj.defaultPage();
Paper temp = pf.getPaper();
temp.setImageableArea(1, 3, temp.getWidth(), temp.getHeight());
pf.setPaper(temp);
if (pj.printDialog(pras)) {
try {
pj.setPrintable(this, pf);
pj.print(pras); // Drucken
return true;
} catch (Exception PrintException) {
.....
}
I tried to give only the attributes to print, only to the dialog, etc. etc. etc. It print's the document 2 times, but not duplex! 我试图只给出要打印的属性,只给对话框等,等等。等等。它打印文档两次,但是不能打印双面! (also tried Sides.TWO_SIDED_LONG_EDGE..)
(也尝试过Sides.TWO_SIDED_LONG_EDGE ..)
问题出在我的打印机上,...始终使双面打印选项被禁用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.