()
| 147 | } |
| 148 | |
| 149 | @Override |
| 150 | public Integer call() |
| 151 | { |
| 152 | RenderingHints renderingHints = null; |
| 153 | |
| 154 | if (noColorOpt) |
| 155 | { |
| 156 | renderingHints = new RenderingHints(null); |
| 157 | renderingHints.put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); |
| 158 | renderingHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); |
| 159 | renderingHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); |
| 160 | } |
| 161 | |
| 162 | try (PDDocument document = Loader.loadPDF(infile, password)) |
| 163 | { |
| 164 | AccessPermission ap = document.getCurrentAccessPermission(); |
| 165 | if (!ap.canPrint()) |
| 166 | { |
| 167 | throw new IOException("You do not have permission to print"); |
| 168 | } |
| 169 | |
| 170 | PrinterJob printJob = PrinterJob.getPrinterJob(); |
| 171 | printJob.setJobName(infile.getName()); |
| 172 | |
| 173 | if (printerName != null) |
| 174 | { |
| 175 | PrintService[] printServices = PrinterJob.lookupPrintServices(); |
| 176 | boolean printerFound = false; |
| 177 | for (PrintService printService : printServices) |
| 178 | { |
| 179 | if (printService.getName().equalsIgnoreCase(printerName)) |
| 180 | { |
| 181 | printJob.setPrintService(printService); |
| 182 | printerFound = true; |
| 183 | break; |
| 184 | } |
| 185 | } |
| 186 | if (!printerFound) |
| 187 | { |
| 188 | SYSERR.println("printer '" + printerName + "' not found, using default '" + |
| 189 | printJob.getPrintService().getName() + "'"); |
| 190 | showAvailablePrinters(); |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | PrintService printService = printJob.getPrintService(); |
| 195 | PrintRequestAttributeSet pras = createPrintRequestAttributeSet(document); |
| 196 | |
| 197 | if (tray != null) |
| 198 | { |
| 199 | // find the object with the same name |
| 200 | boolean found = false; |
| 201 | for (MediaTray mediaTray : getTraysFromPrintService(printService)) |
| 202 | { |
| 203 | if (tray.equals(mediaTray.toString())) |
| 204 | { |
| 205 | pras.add(toPossibleAlternateMedia(mediaTray)); |
| 206 | found = true; |
nothing calls this directly
no test coverage detected