Skip to content

Commit

Permalink
PDFBOX-5911: -1 dpi for automatic calculation
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1922212 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
THausherr committed Nov 29, 2024
1 parent 3007890 commit ccdd420
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pdfbox/src/main/java/org/apache/pdfbox/printing/PDFPrintable.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,18 @@ public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
// rasterize to bitmap (optional)
Graphics2D printerGraphics = null;
BufferedImage image = null;
if (dpi > 0)
if (dpi > 0 || dpi == -1)
{
float dpiScale = dpi / 72;
float dpiScale;
if (dpi == -1)
{
dpiScale = (float) graphics2D.getTransform().getScaleX();
LOG.debug("dpi set to " + Math.round(graphics2D.getTransform().getScaleX() * 72));
}
else
{
dpiScale = dpi / 72;
}
image = new BufferedImage((int)(imageableWidth * dpiScale / scale),
(int)(imageableHeight * dpiScale / scale),
BufferedImage.TYPE_INT_ARGB);
Expand Down

0 comments on commit ccdd420

Please sign in to comment.