You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2023/05/13 12:56:40 UTC
svn commit: r1909793 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
Author: tilman
Date: Sat May 13 12:56:40 2023
New Revision: 1909793
URL: http://svn.apache.org/viewvc?rev=1909793&view=rev
Log:
PDFBOX-5601: avoid terrible output on printer unless TYPE_4BYTE_ABGR
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java?rev=1909793&r1=1909792&r2=1909793&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java Sat May 13 12:56:40 2023
@@ -1282,6 +1282,27 @@ public class PageDrawer extends PDFGraph
}
else
{
+ GraphicsConfiguration graphicsConfiguration = graphics.getDeviceConfiguration();
+ int deviceType = GraphicsDevice.TYPE_RASTER_SCREEN;
+ if (graphicsConfiguration != null)
+ {
+ GraphicsDevice graphicsDevice = graphicsConfiguration.getDevice();
+ if (graphicsDevice != null)
+ {
+ deviceType = graphicsDevice.getType();
+ }
+ }
+ if (deviceType == GraphicsDevice.TYPE_PRINTER &&
+ image.getType() != BufferedImage.TYPE_4BYTE_ABGR)
+ {
+ // PDFBOX-5601: avoid terrible output on printer unless TYPE_4BYTE_ABGR
+ BufferedImage bim = new BufferedImage(
+ image.getWidth(), image.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
+ Graphics g = bim.getGraphics();
+ g.drawImage(image, 0, 0, null);
+ g.dispose();
+ image = bim;
+ }
graphics.drawImage(image, imageTransform, null);
}
}