简体   繁体   English

从Java打印到Epson PictureMate

[英]Printing to an Epson PictureMate from Java

I'm to use the Java printing API to print a JPG to an Epson PictureMate photo printer. 我将使用Java打印API将JPG打印到Epson PictureMate照片打印机。 I want the print to take up the entire page. 我希望打印占用整个页面。 The image prints but it has an eighth of an inch of unprinted space on right edge. 图像已打印,但右侧边缘有八分之一英寸的未打印空间。 Here's the code I'm using: 这是我正在使用的代码:

public void printImage(File image) throws Exception {
  PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
  aset.add(OrientationRequested.REVERSE_LANDSCAPE);
  aset.add(MediaSizeName.JAPANESE_POSTCARD);
  DocPrintJob printerJob = printService.createPrintJob();       
  FileInputStream fis = new FileInputStream(image);
  Doc doc = new SimpleDoc(fis, DocFlavor.INPUT_STREAM.JPEG, null);
  printerJob.print(doc, aset);
  fis.close();
}

I thought the the JAPANESE_POSTCARD size was correct but it seems to small for 4"x6" prints. 我以为JAPANESE_POSTCARD大小是正确的,但对于4“ x6”的打印来说似乎很小。 I also tried setting MediaPrintableArea to 4"x6" but that didn't work either. 我也尝试将MediaPrintableArea设置为4“ x6”,但这也不起作用。 Any ideas? 有任何想法吗?

I know there is some (potential) internal wrangling of the Paper that goes on after you pass it to the PrintJob , basically it's trying to valid that the paper size and margins can work with the specified printer (from experience). 我知道在将Paper传递给PrintJob之后,Paper会发生一些(潜在的)内部纠纷,基本上是在尝试验证纸张的大小和边距是否可以与指定的打印机配合使用(根据经验)。

However, you might to take a read of http://www.jpedal.org/PDFblog/2009/06/java-printing-page-size-problem/ as it might have some ideas on how to over come some of them. 但是,您可能需要阅读http://www.jpedal.org/PDFblog/2009/06/java-printing-page-size-problem/,因为它可能对如何克服其中的一些想法有所帮助。

As to how to them apply that back to the PrintService s API is another question ;) 至于如何将它们应用回PrintService的API是另一个问题;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM