Skip to content

Commit ccdd420

Browse files
committed
PDFBOX-5911: -1 dpi for automatic calculation
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1922212 13f79535-47bb-0310-9956-ffa450edef68
1 parent 3007890 commit ccdd420

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

pdfbox/src/main/java/org/apache/pdfbox/printing/PDFPrintable.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,18 @@ public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
253253
// rasterize to bitmap (optional)
254254
Graphics2D printerGraphics = null;
255255
BufferedImage image = null;
256-
if (dpi > 0)
256+
if (dpi > 0 || dpi == -1)
257257
{
258-
float dpiScale = dpi / 72;
258+
float dpiScale;
259+
if (dpi == -1)
260+
{
261+
dpiScale = (float) graphics2D.getTransform().getScaleX();
262+
LOG.debug("dpi set to " + Math.round(graphics2D.getTransform().getScaleX() * 72));
263+
}
264+
else
265+
{
266+
dpiScale = dpi / 72;
267+
}
259268
image = new BufferedImage((int)(imageableWidth * dpiScale / scale),
260269
(int)(imageableHeight * dpiScale / scale),
261270
BufferedImage.TYPE_INT_ARGB);

0 commit comments

Comments
 (0)