Class PrintPDF

  • All Implemented Interfaces:
    java.util.concurrent.Callable<java.lang.Integer>

    public final class PrintPDF
    extends java.lang.Object
    implements java.util.concurrent.Callable<java.lang.Integer>
    This is a command line program that will print a PDF document.
    • Field Detail

      • SYSERR

        private final java.io.PrintStream SYSERR
      • password

        private java.lang.String password
      • silentPrint

        private boolean silentPrint
      • printerName

        private java.lang.String printerName
      • tray

        private java.lang.String tray
      • mediaSize

        private java.lang.String mediaSize
      • border

        private boolean border
      • dpi

        private int dpi
      • noCenter

        private boolean noCenter
      • noColorOpt

        private boolean noColorOpt
      • infile

        private java.io.File infile
    • Constructor Detail

      • PrintPDF

        public PrintPDF()
        Constructor.
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
        Infamous main method.
        Parameters:
        args - Command line arguments, should be one and a reference to a file.
      • call

        public java.lang.Integer call()
        Specified by:
        call in interface java.util.concurrent.Callable<java.lang.Integer>
      • getTraysFromPrintService

        private static java.util.List<javax.print.attribute.standard.MediaTray> getTraysFromPrintService​(javax.print.PrintService printService)
      • getMediaSizesFromPrintService

        private static java.util.List<javax.print.attribute.standard.MediaSizeName> getMediaSizesFromPrintService​(javax.print.PrintService printService)
      • createPrintRequestAttributeSet

        private javax.print.attribute.PrintRequestAttributeSet createPrintRequestAttributeSet​(PDDocument document)
      • toPossibleAlternateMedia

        private javax.print.attribute.Attribute toPossibleAlternateMedia​(javax.print.attribute.standard.MediaTray mediaTray)
        Wraps the MediaTray object into a sun.print.SunAlternateMedia class if it exists. This allows to select both tray and paper size when printing.
        Parameters:
        mediaTray - a MediaTray object.
        Returns:
        a wrapped MediaTray object or the original MediaTray object.
      • showAvailablePrinters

        private void showAvailablePrinters()