Note that there are some explanatory texts on larger screens.

plurals
  1. POPrinting in Java - Printable.print() resizes images
    primarykey
    data
    text
    <p>I have a custom report which draws via <code>Graphics2D</code>, and uses a lot of tiny <code>BufferedImage</code> sprites. <code>PrinterJob.print()</code> seems to be calling <code>Printable.print()</code> roughly once for each sprite (the actual count can vary both ways), so some pages are re-rendered 150 times... This causes printing to be unacceptably slow, about 10 seconds for two pages.</p> <p>I found this: <a href="https://stackoverflow.com/questions/1943556/why-does-the-java-printables-print-method-get-called-multiple-times-with-the-sa">Why does the java Printable&#39;s print method get called multiple times with the same page number?</a></p> <p>But it doesn't appear to explain my particular problem (or only partially explains it). I created a test report which has only a few sprites, and there was a small number of resizes that went up and down as I added and removed images on either the vertical or horizontal axes.</p> <p>When printing to a PDF using Bullzip, I noticed that after zooming in on the images, they are being scaled up using a bilinear or bicubic algorithm. One of these images, which is unique in having an indexed color palette, does not appear to be scaled. I confirmed that the scaling is a Java behavior and not being performed by Bullzip by printing to a real printer and observing the same images being scaled versus not.</p> <p>So it strikes me as the print API trying to rescale images to whatever DPI it has in mind, but for some reason it's calling <code>Printable.print()</code> each time it encounters an image that it deems as needing this treatment.</p> <p>How do I fix this behavior? I tried setting rendering hints on the <code>Graphics2D</code> that I get when <code>Printable.print()</code> is called, to no avail. I don't know what else to do short of try to find and examine the print API's source code.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload