MCPcopy Index your code
hub / github.com/apache/pdfbox / call

Method call

tools/src/main/java/org/apache/pdfbox/tools/PrintPDF.java:149–257  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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;

Callers

nothing calls this directly

Calls 15

loadPDFMethod · 0.95
canPrintMethod · 0.95
showAvailablePrintersMethod · 0.95
setRenderingHintsMethod · 0.95
putMethod · 0.65
getNameMethod · 0.65
equalsMethod · 0.45

Tested by

no test coverage detected