我想在热敏打印机上打印一个图像,但是当我使用这个代码时,图像会变小。如何更改要打印的图像的大小?
public void printPhoto() throws Exception {
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
pras.add(new Copies(1));
pras.size();
PrintService pss[] = PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.PNG, pras);
if (pss.length == 0)
throw new RuntimeException("No printer services available.");
PrintService ps = findPrintService("POS-58", pss);
System.out.println("Printing to " + ps);
DocPrintJob job = ps.createPrintJob();
FileInputStream fin = new FileInputStream("D:\\QRCODE\\test.png");
Doc doc = new SimpleDoc(fin, DocFlavor.INPUT_STREAM.PNG, null);
job.print(doc, pras);
fin.close();
}
有人能帮我吗?这是我们学校的项目。谢谢。
1条答案
按热度按时间f8rj6qna1#
我把代码改成这个