问题描述
我在尝试使Java应用程序在Mac设备上打印2面(双面)时遇到麻烦。我已经测试了Mac OS 10.12、10.14和10.15。使用具有双面打印功能的brother打印机,它在Windows中可以正常工作,但是当我在Mac上运行相同的代码时,它仅打印单面。没有错误,文档始终总是单面打印。
以下是我正在使用的代码示例:
public class PrintTwoSided
{
public static void main(String[] args)
{
try
{
System.out.println(System.getProperty("java.version"));
PrinterJob job = PrinterJob.getPrinterJob();
PrintService printer = job.getPrintService();
PDFDocument doc = new PDFDocument("/test/print.pdf",null);
job.setPrintable(doc);
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
boolean isTwoSidedSupported = printer.isAttributeValueSupported(Sides.TWO_SIDED_LONG_EDGE,null,null);
System.out.println("isTwoSidedSupported: " + isTwoSidedSupported);
aset.add(Sides.TWO_SIDED_LONG_EDGE);
job.print(aset);
}
catch (Exception ex)
{
ex.printstacktrace();
}
}
}
这似乎发生在多个Java版本中,包括我测试过的1.7和1.8。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)