pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1829374 - /pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java
Date Tue, 17 Apr 2018 17:26:46 GMT
Author: tilman
Date: Tue Apr 17 17:26:46 2018
New Revision: 1829374

URL: http://svn.apache.org/viewvc?rev=1829374&view=rev
Log:
PDFBOX-4192: support subsampling

Modified:
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java?rev=1829374&r1=1829373&r2=1829374&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java Tue Apr 17 17:26:46
2018
@@ -58,6 +58,7 @@ public final class PDFToImage
     private static final String QUALITY = "-quality";
     private static final String CROPBOX = "-cropbox";
     private static final String TIME = "-time";
+    private static final String SUBSAMPLING = "-subsampling";
 
     /**
      * private constructor.
@@ -104,6 +105,7 @@ public final class PDFToImage
         float cropBoxUpperRightX = 0;
         float cropBoxUpperRightY = 0;
         boolean showTime = false;
+        boolean subsampling = false;
         try
         {
             dpi = Toolkit.getDefaultToolkit().getScreenResolution();
@@ -185,6 +187,9 @@ public final class PDFToImage
                 case TIME:
                     showTime = true;
                     break;
+                case SUBSAMPLING:
+                    subsampling = true;
+                    break;
                 default:
                     if (pdfFile == null)
                     {
@@ -248,6 +253,7 @@ public final class PDFToImage
                 boolean success = true;
                 endPage = Math.min(endPage, document.getNumberOfPages());
                 PDFRenderer renderer = new PDFRenderer(document);
+                renderer.setSubsamplingAllowed(subsampling);
                 for (int i = startPage - 1; i < endPage; i++)
                 {
                     BufferedImage image = renderer.renderImageWithDPI(i, dpi, imageType);
@@ -293,6 +299,7 @@ public final class PDFToImage
             + "  -quality <float>                 : The quality to be used when compressing
the image (0 < quality <= 1 (default))\n"
             + "  -cropbox <int> <int> <int> <int> : The page area
to export\n"
             + "  -time                            : Prints timing information to stdout\n"
+            + "  -subsampling                     : Activate subsampling (for PDFs with huge
images)\n"
             + "  <inputfile>                      : The PDF document to use\n";
         
         System.err.println(message);



Mime
View raw message