You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ja...@apache.org on 2014/03/06 23:43:56 UTC

svn commit: r1575080 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java

Author: jahewson
Date: Thu Mar  6 22:43:56 2014
New Revision: 1575080

URL: http://svn.apache.org/r1575080
Log:
PDFBOX-1963: allow PDF to be rendered using DPI as suggested by Tilman

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java?rev=1575080&r1=1575079&r2=1575080&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java Thu Mar  6 22:43:56 2014
@@ -71,6 +71,31 @@ public class PDFRenderer
     }
 
     /**
+     * Returns the given page as an RGB image at the given DPI.
+     * @param pageIndex the zero-based index of the page to be converted
+     * @param dpi the DPI (dots per inch) to render at
+     * @return the rendered page image
+     * @throws IOException if the PDF cannot be read
+     */
+    public BufferedImage renderImageWithDPI(int pageIndex, int dpi) throws IOException
+    {
+        return renderImage(pageIndex, dpi / 72f, false);
+    }
+
+    /**
+     * Returns the given page as an RGB image at the given DPI.
+     * @param pageIndex the zero-based index of the page to be converted
+     * @param dpi the DPI (dots per inch) to render at
+     * @return the rendered page image
+     * @throws IOException if the PDF cannot be read
+     */
+    public BufferedImage renderImageWithDPI(int pageIndex, int dpi, boolean useAlpha)
+            throws IOException
+    {
+        return renderImage(pageIndex, dpi / 72f, useAlpha);
+    }
+
+    /**
      * Returns the given page as an RGB or ARGB image at the given scale.
      * @param pageIndex the zero-based index of the page to be converted
      * @param scale the scaling factor, where 1 = 72 DPI