【发布时间】:2019-07-08 13:40:30
【问题描述】:
我正在尝试打印一个我认为是横向模式的文件(它的尺寸为 29.7 x 27 厘米),但是当我提交 job.print() 时我的程序停止工作。这是我的代码:
PDDocument documentAllegato = PDDocument.load(new File(percorsoDaStampare +"\\"+ fileInDaStampare[k].getName()));
System.out.println("oo");
job.setPageable(new PDFPageable(documentAllegato));
System.out.println("pp");
Attribute[] attributeArray2 = attributes.toArray();
for (Attribute a : attributeArray2) {
//System.out.println(a.getName() + ": " + a);
}
System.out.println("qq");
Attribute copies2 = attributes.get(Copies.class);
Attribute media2 = attributes.get(Media.class);
Attribute mediaPrintableArea2 = attributes.get(MediaPrintableArea.class);
Attribute mediaTray2 = attributes.get(MediaTray.class);
Attribute orientationRequested2 = attributes.get(OrientationRequested.class);
Attribute sides2 = attributes.get(Sides.class);
System.out.println("rr");
attributes.remove(Sides.class);
attributes.add(Sides.DUPLEX);
//System.out.println("PRIMA DEL PRINT");
System.out.println("ss");
job.print();
System.out.println("tt");
documentAllegato.close(); //chiudo il documento
//System.out.println("Ho finito di stampare la copia cortesia");
System.out.println("uu");
//sposto la copia di cortesia in ARCHIVIATI
File dirArchiviati = new File(pathArchiviati);
File fileCortesiaDaArch= new File(""+fileInDaStampare[k]);
System.out.println("vv");
FileUtils.copyFileToDirectory(fileCortesiaDaArch, dirArchiviati);
//System.out.println("fileDaArch "+ fileCortesiaDaArch);
System.out.println("zz");
fileCortesiaDaArch.delete();
System.out.println("FINE ALLEGATO");
我尝试将其置于纵向模式以修改一些内容,但我无法获得它。有什么建议吗?
【问题讨论】:
-
您的意思是 29,7 x 20,7 厘米? A4 横向。
-
是的,我有这个 pdf,其中页面是 A4 横向,我的代码在“job.print()”行上停止工作。我在 A4 纵向打印文件时没有错误。
-
我自己我不知道。用 java -Xmx1g 之类的增加内存。或在
job.print();之前致电documentAllegato.close(); -
我在其他文件上使用了相同的功能,它可以工作。唯一的区别是有问题的是横向模式下的pdf。
-
您似乎已接近错误。如果没有人遇到此错误并提供答案,请尽量减少应用程序。风景没什么特别的,也许更多的记忆。