Extracts the images from a PDF file. @author Ben Litchfield
| 68 | * @author Ben Litchfield |
| 69 | */ |
| 70 | @Command(name = "extractimages", header = "Extracts the images from a PDF document", versionProvider = Version.class, mixinStandardHelpOptions = true) |
| 71 | public final class ExtractImages implements Callable<Integer> |
| 72 | { |
| 73 | // Expected for CLI app to write to System.out/System.err |
| 74 | @SuppressWarnings("squid:S106") |
| 75 | private final PrintStream SYSOUT; |
| 76 | @SuppressWarnings("squid:S106") |
| 77 | private final PrintStream SYSERR; |
| 78 | |
| 79 | private static final List<String> JPEG = Arrays.asList( |
| 80 | COSName.DCT_DECODE.getName(), |
| 81 | COSName.DCT_DECODE_ABBREVIATION.getName()); |
| 82 | |
| 83 | @Option(names = "-password", description = "the password for the PDF or certificate in keystore.", arity = "0..1", interactive = true) |
| 84 | private String password; |
| 85 | |
| 86 | @Option(names = "-prefix", description = "the image prefix (default to pdf name).") |
| 87 | private String prefix; |
| 88 | |
| 89 | @Option(names = "-useDirectJPEG", description = "Forces the direct extraction of JPEG/JPX images " + |
| 90 | "regardless of colorspace or masking.") |
| 91 | private boolean useDirectJPEG; |
| 92 | |
| 93 | @Option(names = "-noColorConvert", description = "Images are extracted with their " + |
| 94 | "original colorspace if possible.") |
| 95 | private boolean noColorConvert; |
| 96 | |
| 97 | @Option(names = {"-i", "--input"}, description = "the PDF file", required = true) |
| 98 | private File infile; |
| 99 | |
| 100 | private final Set<COSStream> seen = new HashSet<>(); |
| 101 | private int imageCounter = 1; |
| 102 | |
| 103 | /** |
| 104 | * Constructor. |
| 105 | */ |
| 106 | public ExtractImages() |
| 107 | { |
| 108 | SYSOUT = System.out; |
| 109 | SYSERR = System.err; |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Entry point for the application. |
| 114 | * |
| 115 | * @param args The command-line arguments. |
| 116 | */ |
| 117 | public static void main(String[] args) |
| 118 | { |
| 119 | // suppress the Dock icon on OS X |
| 120 | System.setProperty("apple.awt.UIElement", "true"); |
| 121 | |
| 122 | int exitCode = new CommandLine(new ExtractImages()).execute(args); |
| 123 | System.exit(exitCode); |
| 124 | } |
| 125 | |
| 126 | public Integer call() |
| 127 | { |
nothing calls this directly
no test coverage detected
searching dependent graphs…