详情页.pdf (9.4 MB)
public static void main(String[] args) throws FileNotFoundException {
String inputFileName = Paths.get(“详情页.pdf”).toString();
Document pdfDocument = new Document(inputFileName);
List list = new ArrayList<>(pdfDocument.getPages().size());
try {
for (int pageCount = 1; pageCount <= pdfDocument.getPages().size(); pageCount++) {
// Create stream object to save the output image
String outputFilePath = “aa.jpg”;
final Instant now = Instant.now();
java.io.OutputStream imageStream = new java.io.FileOutputStream(outputFilePath);
JpegDevice JpegDevice = new JpegDevice(50);
JpegDevice.process(pdfDocument.getPages().get_Item(pageCount), imageStream);
imageStream.close();
}
} finally {
if (pdfDocument != null) {
pdfDocument.dispose();
}
}
}