프린터에 PNG 이미지를 인쇄 중입니다. 이미지는 페이지 중앙에 인쇄되며 전체 페이지를 채우지 않습니다. 나는 이미지의 크기를 늘리려고했지만 항상 페이지의 중앙에 위치시켰다. 어떤 아이디어라도 페이지에 맞게 만드는 방법은 무엇입니까?이미지를 인쇄 할 때 페이지에 맞추기
psStream = new URL(url).openStream();
if (psStream == null) {
return "Unable to fetch image";
}
DocFlavor flavor = DocFlavor.INPUT_STREAM.PNG;
Doc myDoc = new SimpleDoc(psStream, flavor, null);
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
PrintServiceAttributeSet attributes = new HashPrintServiceAttributeSet();
attributes.add(new PrinterName(printData.printer, Locale.getDefault()));
final PrintService[] printServices = PrintServiceLookup.lookupPrintServices(flavor, attributes);
if (printServices.length == 0) {
return "Could not find printer " + printData.printer;
} else {
myPrinter = printServices[0];
DocPrintJob job = myPrinter.createPrintJob();
try {
job.print(myDoc, aset);
return null;
} catch (Exception e) {
e.printStackTrace();
return "Could not print : " + e.getMessage();
}
}
중복 된 http://stackoverflow.com/questions/27029166/java-printerjob-not-printing-to-fit-paper – SomeDude