()
| 118 | } |
| 119 | |
| 120 | public Integer call() |
| 121 | { |
| 122 | if (outputPrefix == null) |
| 123 | { |
| 124 | outputPrefix = FilenameUtils.removeExtension(infile.getAbsolutePath()); |
| 125 | } |
| 126 | |
| 127 | List<String> writerFormatNames = Arrays.asList(ImageIO.getWriterFormatNames()); |
| 128 | if (!writerFormatNames.contains(imageFormat)) |
| 129 | { |
| 130 | String wfn = writerFormatNames.stream().collect(Collectors.joining(", ")); |
| 131 | SYSERR.println("Error: Invalid image format " + imageFormat + " - supported formats: " + |
| 132 | wfn); |
| 133 | return 2; |
| 134 | } |
| 135 | |
| 136 | if (quality < 0) |
| 137 | { |
| 138 | quality = "png".equals(imageFormat) ? 0f : 1f; |
| 139 | } |
| 140 | |
| 141 | if (dpi == 0) |
| 142 | { |
| 143 | try |
| 144 | { |
| 145 | dpi = Toolkit.getDefaultToolkit().getScreenResolution(); |
| 146 | } |
| 147 | catch (HeadlessException e) |
| 148 | { |
| 149 | dpi = 96; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | try (PDDocument document = Loader.loadPDF(infile, password)) |
| 154 | { |
| 155 | PDAcroForm acroForm = document.getDocumentCatalog().getAcroForm(); |
| 156 | if (acroForm != null && acroForm.getNeedAppearances()) |
| 157 | { |
| 158 | acroForm.refreshAppearances(); |
| 159 | } |
| 160 | |
| 161 | if (cropbox != null) |
| 162 | { |
| 163 | changeCropBox(document, cropbox[0], cropbox[1], cropbox[2], cropbox[3]); |
| 164 | } |
| 165 | |
| 166 | long startTime = System.nanoTime(); |
| 167 | |
| 168 | // render the pages |
| 169 | if (page != -1) |
| 170 | { |
| 171 | startPage = page; |
| 172 | endPage = page; |
| 173 | } |
| 174 | boolean success = true; |
| 175 | endPage = Math.min(endPage, document.getNumberOfPages()); |
| 176 | PDFRenderer renderer = new PDFRenderer(document); |
| 177 | renderer.setSubsamplingAllowed(subsampling); |
nothing calls this directly
no test coverage detected