WPrinterJob_drawDIBImage打印时出现InternalError

时间:2012-01-17 07:46:31

标签: java image printing

尝试使用java Print Service API通过FileInputStream打印JPEG时,我们有时会遇到以下异常:

Caused by: java.lang.InternalError: Problem in WPrinterJob_drawDIBImage
    at sun.awt.windows.WPrinterJob.drawDIBImage(Native Method)
    at sun.awt.windows.WPrinterJob.drawDIBImage(Unknown Source)
    at sun.awt.windows.WPathGraphics.drawImageToPlatform(Unknown Source)
    at sun.print.PathGraphics.drawImage(Unknown Source)
    at sun.print.PathGraphics.drawImage(Unknown Source)
    at sun.print.ImagePrinter.print(Unknown Source)
    at sun.print.RasterPrinterJob.printPage(Unknown Source)
    at sun.print.RasterPrinterJob.print(Unknown Source)
    at sun.print.Win32PrintJob.printableJob(Unknown Source)
    at sun.print.Win32PrintJob.print(Unknown Source)
    at com.magicmemories.mpower.printing.AbstractPrinter.printDoc(Unknown Source)
    at com.magicmemories.mpower.printing.JPEGPrinter.print(Unknown Source)
    at com.magicmemories.mpower.printing.PrintProducer.print(Unknown Source)
    at com.magicmemories.mpower.product.D2PProducer.produce(Unknown Source)
    at com.magicmemories.mpower.tasks.PrintProductTask.call(Unknown Source)
    at com.magicmemories.mpower.tasks.PrintProductTask.call(Unknown Source)
    ... 5 more

执行打印的代码如下所示:

Doc printDoc = new SimpleDoc(new FileInputStream(jpegFile), DocFlavor.INPUT_STREAM.JPEG, null);
DocPrintJob printJob = printService.createPrintJob();
printJob.print(printDoc, printAttributes);

我们打印的实际JPEG是动态生成的 - 通常约为2MB。我拍摄了一些无法打印的图像,并将它们放入一个对API进行相同调用的测试脚本中,因此我相信图像本身没有任何问题。

每次都不会发生异常,大约每50或100次打印一次。它已在32位Java 6 Oracle JVM上看到,它们都更新26和更新30.由于它是间歇性的,我们认为它是某种内存问题。我们已经在jconsole中打印时监视应用程序,并且当它有超过100MB的堆空间时,抛出了异常。目前,该应用程序在具有2GB RAM的WinXP盒上运行时具有1GB的堆空间。我们已经订购了更多RAM的采购订单,以便我们可以尝试增加堆空间,但是因为它似乎没有达到它的限制,我们并不乐观,这将解决它。

当我们等待额外的RAM到达时,还有什么我们可以做的来尝试解决这个问题吗?

0 个答案:

没有答案