pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1793842 - /pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PrintPDF.java
Date Thu, 04 May 2017 18:15:33 GMT
Author: tilman
Date: Thu May  4 18:15:32 2017
New Revision: 1793842

URL: http://svn.apache.org/viewvc?rev=1793842&view=rev
Log:
PDFBOX-3779: add border and dpi parameter

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

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PrintPDF.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PrintPDF.java?rev=1793842&r1=1793841&r2=1793842&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PrintPDF.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PrintPDF.java Thu May  4 18:15:32
2017
@@ -39,6 +39,8 @@ public final class PrintPDF
     private static final String SILENT = "-silentPrint";
     private static final String PRINTER_NAME = "-printerName";
     private static final String ORIENTATION = "-orientation";
+    private static final String BORDER = "-border";
+    private static final String DPI = "-dpi";
 
     /**
      * private constructor.
@@ -65,6 +67,8 @@ public final class PrintPDF
         boolean silentPrint = false;
         String printerName = null;
         Orientation orientation = Orientation.AUTO;
+        boolean showPageBorder = false;
+        int dpi = 0;
         Map <String,Orientation> orientationMap = new HashMap<>();
         orientationMap.put("auto", Orientation.AUTO);
         orientationMap.put("landscape", Orientation.LANDSCAPE);
@@ -104,6 +108,17 @@ public final class PrintPDF
                         usage();
                     }
                     break;
+                case BORDER:
+                    showPageBorder = true;
+                    break;
+                case DPI:
+                    i++;
+                    if (i >= args.length)
+                    {
+                        usage();
+                    }
+                    dpi = Integer.parseInt(args[i]);
+                    break;
                 default:
                     pdfFile = args[i];
                     break;
@@ -133,7 +148,7 @@ public final class PrintPDF
                     }
                 }
             }
-            printJob.setPageable(new PDFPageable(document, orientation));
+            printJob.setPageable(new PDFPageable(document, orientation, showPageBorder, dpi));
             
             if (silentPrint || printJob.printDialog())
             {
@@ -151,7 +166,11 @@ public final class PrintPDF
                 + "\nOptions:\n"
                 + "  -password  <password>                : Password to decrypt document\n"
                 + "  -printerName <name>                  : Print to specific printer\n"
-                + "  -orientation auto|portrait|landscape : Print using orientation (default:
auto)\n"
+                + "  -orientation auto|portrait|landscape : Print using orientation\n"
+                + "                                           (default: auto)\n"
+                + "  -border                              : Print with border\n"
+                + "  -dpi                                 : Render into intermediate image
with\n"
+                + "                                           specific dpi and then print\n"
                 + "  -silentPrint                         : Print without printer dialog
box\n";
         
         System.err.println(message);



Mime
View raw message