This content has been marked as final. Show 1 reply
Java printing framework assumes by default 72 DPI. The printer graphics typically has a transformation to scale from 72 DPI to printer's resolution.
To achieve better quality the simplest approach is to scale down printer graphics and to scale up by the same factor destination rectangle in RenderOptions.
E.G. here is modified code snippet from AWTSample:
final double scale = 2.0;
Rectangle pageRect = new Rectangle((int)(pageFormat.getImageableX() * scale),
(int)(pageFormat.getImageableY() * scale),
(int)(pageFormat.getImageableWidth() * scale),
(int)(pageFormat.getImageableHeight() * scale));
For best quality you need to reset the graphics transform to identity and scale destination rectangle by scale factor that graphics originally had, but in this case you will need to band data that you send to printer (call renderOntoGraphics() in a loop, shifting source and destination), otherwise for some file formats you will easily run out of memory.
Hope this helps. Let me know if you still have issues with it.