Sorry it took so long to respond - I had to get permission to share these.

I did test with 2.0.24 and it did not help.


Here are some files that cause the problem:

https://github.com/trumpetinc/boottest/blob/main/JrachvUniverse_H21.pdf
https://github.com/trumpetinc/boottest/blob/main/PP%20Opera%20Building_A53.pdf


Here is some quick code that demonstrates the problem (update for your
printer name and PDF path):

https://github.com/trumpetinc/boottest/blob/main/SimplifiedPdfBoxPdfPrinter.java



Maybe in TilingPaint#getImage(PageDrawer, PDTilingPattern, PDColorSpace,
PDColor, AffineTransform, Rectangle2D), the BufferedImage could
benefit from something similar to BigBufferedImage described in this post?
(
https://stackoverflow.com/questions/3854200/why-does-a-bufferedimage-require-so-much-memory-beyond-the-size-of-its-data-arra
).  Or maybe there is something in the scaling logic?






On Thu, Oct 28, 2021 at 11:12 AM Tilman Hausherr <thaush...@t-online.de>
wrote:

> Huge buffered images can happen in patterns if the pattern matrix and/or
> the current transformation matrix result in a huge scale.
>
> You could retry with 2.0.24, but I'm pessimistic. Please share the PDF
> (upload to a sharehoster).
>
> Tilman
>
> Am 28.10.2021 um 01:17 schrieb Kevin Day:
> > Using PDFBox 2.0.20
> >
> > We use the following to print the PDF:
> >
> >      HashPrintRequestAttributeSet attributes = new
> > HashPrintRequestAttributeSet();
> >
> >      try(PDDocument doc = PDDocument.load(pdf,
> > MemoryUsageSetting.setupMixed(5000000L))){
> >          job.setPageable(new PDFPageable(doc));
> >          job.print(attributes);
> >      }
> >
> > This works really well for thousands of PDFs, but we've run into one
> > particular PDF that causes an OutOfMemoryException.
> >
> >
> > The problem PDF is rendered (does not contain bitmaps).
> >
> > I've provided a huge amount of heap (over 1GB now), and it is still
> failing.
> >
> > As near as I can tell from the stack trace (which I'll include below), it
> > seems like the problem is with creation of a huge buffered image.
> >
> > The physical page size in the PDF is 8.5 x 11".
> >
> > The PDFPrintable is configured as follows:
> >
> > Scaling is ACTUAL_SIZE
> > dpi is 0.0
> > subsamplingAllowed is false
> > renderingHints is null
> >
> >
> > Here is the stack trace:
> >
> > java.lang.OutOfMemoryError: Java heap space
> > at
> java.desktop/java.awt.image.DataBufferInt.<init>(DataBufferInt.java:75)
> > at java.desktop/java.awt.image.Raster.createPackedRaster(Raster.java:467)
> > at
> >
> java.desktop/java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1032)
> > at
> java.desktop/java.awt.image.BufferedImage.<init>(BufferedImage.java:333)
> > at org.apache.pdfbox.rendering.TilingPaint.getImage(TilingPaint.java:143)
> > at org.apache.pdfbox.rendering.TilingPaint.<init>(TilingPaint.java:103)
> > at
> >
> org.apache.pdfbox.rendering.TilingPaintFactory.create(TilingPaintFactory.java:60)
> > at org.apache.pdfbox.rendering.PageDrawer.getPaint(PageDrawer.java:351)
> > at
> >
> org.apache.pdfbox.rendering.PageDrawer.getNonStrokingPaint(PageDrawer.java:719)
> > at org.apache.pdfbox.rendering.PageDrawer.fillPath(PageDrawer.java:819)
> > at
> >
> org.apache.pdfbox.contentstream.operator.graphics.FillEvenOddRule.process(FillEvenOddRule.java:37)
> > at
> >
> org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:932)
> > at
> >
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:510)
> > at
> >
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:484)
> > at
> >
> org.apache.pdfbox.contentstream.PDFStreamEngine.showForm(PDFStreamEngine.java:187)
> > at org.apache.pdfbox.rendering.PageDrawer.showForm(PageDrawer.java:1462)
> > at
> >
> org.apache.pdfbox.contentstream.operator.graphics.DrawObject.process(DrawObject.java:86)
> > at
> >
> org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:932)
> > at
> >
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:510)
> > at
> >
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:484)
> > at
> >
> org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:156)
> > at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:271)
> > at
> >
> org.apache.pdfbox.rendering.PDFRenderer.renderPageToGraphics(PDFRenderer.java:431)
> > at org.apache.pdfbox.printing.PDFPrintable.print(PDFPrintable.java:246)
> > at
> >
> java.desktop/sun.print.RasterPrinterJob.printPage(RasterPrinterJob.java:2430)
> > at
> java.desktop/sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1654)
> >
> >
> >
> > Next, I tried setting subsampling to true - this made no difference.
> >
> >
> > Next, I tried hard coding the dpi to 300f - this works with no problems.
> >
> >
> > Next, I tried hard coding the dpi to 600f - this does not throw the heap
> > space error - but with strange results:
> > - I see "java.lang.OutOfMemoryError" on sys.err - it does NOT throw an
> > exception
> > - The pages come off the printer as blank pages
> >
> >
> > Does anyone have any suggestions on how we can print using the printer's
> > full resolution?
> >
> > Thanks!
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
> For additional commands, e-mail: users-h...@pdfbox.apache.org
>
>

Reply via email to