pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1801495 - /pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java
Date Mon, 10 Jul 2017 16:57:34 GMT
Author: tilman
Date: Mon Jul 10 16:57:34 2017
New Revision: 1801495

URL: http://svn.apache.org/viewvc?rev=1801495&view=rev
Log:
PDFBOX-3863: support duplex entry in ViewerPreferences

Modified:
    pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java

Modified: pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java?rev=1801495&r1=1801494&r2=1801495&view=diff
==============================================================================
--- pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java (original)
+++ pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java Mon Jul
10 16:57:34 2017
@@ -44,6 +44,9 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Properties;
 import java.util.Set;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.attribute.standard.Sides;
 import javax.swing.AbstractAction;
 import javax.swing.Action;
 import javax.swing.JCheckBoxMenuItem;
@@ -106,6 +109,7 @@ import org.apache.pdfbox.debugger.ui.Zoo
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.common.PDPageLabels;
 import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException;
+import org.apache.pdfbox.pdmodel.interactive.viewerpreferences.PDViewerPreferences;
 import org.apache.pdfbox.printing.PDFPageable;
 
 /**
@@ -1220,9 +1224,27 @@ public class PDFDebugger extends JFrame
             {
                 PrinterJob job = PrinterJob.getPrinterJob();
                 job.setPageable(new PDFPageable(document));
-                if (job.printDialog())
+                PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
+                PDViewerPreferences vp = document.getDocumentCatalog().getViewerPreferences();
+                if (vp != null && vp.getDuplex() != null)
                 {
-                    job.print();
+                    String dp = vp.getDuplex();
+                    if (PDViewerPreferences.DUPLEX.DuplexFlipLongEdge.toString().equals(dp))
+                    {
+                        pras.add(Sides.TWO_SIDED_LONG_EDGE);
+                    }
+                    else if (PDViewerPreferences.DUPLEX.DuplexFlipShortEdge.toString().equals(dp))
+                    {
+                        pras.add(Sides.TWO_SIDED_SHORT_EDGE);
+                    }
+                    else if (PDViewerPreferences.DUPLEX.Simplex.toString().equals(dp))
+                    {
+                        pras.add(Sides.ONE_SIDED);
+                    }                    
+                }
+                if (job.printDialog(pras))
+                {
+                    job.print(pras);
                 }
             }
             catch (PrinterException e)



Mime
View raw message