为了账号安全,请及时绑定邮箱和手机立即绑定

当我单击“打印”对话框的“属性”按钮并打印后

当我单击“打印”对话框的“属性”按钮并打印后

万千封印 2021-10-17 10:36:52
我正在打印 Legal 尺寸的纸张,当我在没有打开属性对话框的情况下打印它时,它可以正常打印,但是当我点击“属性”按钮确认页面类型时(无论我点击“确定”还是“取消”然后纸张imageableArea 在带有属性按钮的job.print(attributeSet)对话框中发生变化预期高度/宽度:612/1008实际高度/宽度:612/792(在 WPrinterJob.validatePaper() 中设置)打印有问题的页面这是我的代码,private void preparePageFormat(PageFormat pf){   Paper ppr = new Paper();   pf.setOrientation(PageFormat.LANDSCAPE);   MediaSizeName msn = MediaSizeName.NA_LEGAL;   MediaSize msz = MediaSize.getMediaSizeForName(msn);   double inch = 72.0;   width = msz.getX(MediaSize.INCH) * inch;   height = msz.getY(MediaSize.INCH) * inch;   ppr.setSize(a4Width, a4Height);   ppr.setImageableArea(0, 0, a4Width, a4Height);   pf.setPaper(ppr); }main(){  PrinterJob job = PrinterJob.getPrinterJob();  PageFormat pageFormat = job.defaultPage();  preparePageFormat(pageFormat);  job.setPrintable(previewPanel.getPrintable(), pageFormat);  PrintRequestAttributeSet attributeSet  = new HashPrintRequestAttributeSet();  attributeSet.add(OrientationRequested.LANDSCAPE);  attributeSet.add(MediaSizeName.NA_LEGAL);  if (job.printDialog(attributeSet))  {    attributeSet.add(new MediaPrintableArea((float)pageFormat.getImageableX(),(float)pageFormat.getImageableY(),                        (float)pageFormat.getImageableWidth(),(float)pageFormat.getImageableHeight(),MediaPrintableArea.INCH));     job.print(attributeSet);  }}
查看完整描述

1 回答

?
慕斯王

TA贡献1864条经验 获得超2个赞

对于此打印机问题,您需要确认打印机属性中的设置。验证所有设置都与您的页面类型匹配。

//img1.sycdn.imooc.com//616b8c73000112ab06270555.jpg

也在这里验证。

//img1.sycdn.imooc.com//616b8c830001458109440553.jpg

查看完整回答
反对 回复 2021-10-17
  • 1 回答
  • 0 关注
  • 112 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信