/**
* 将pdf转成img
*/
public static void changePdfToImg() {
try {
File file = new File("E:\\test\\baseInfo_2.pdf");
RandomAccessFile raf = new RandomAccessFile(file, "r");
FileChannel channel = raf.getChannel();
MappedByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
PDFFile pdffile = new PDFFile(buf);
for (int i = 1; i <= pdffile.getNumPages(); i++) {
PDFPage page = pdffile.getPage(i);
Rectangle rect = new Rectangle(0, 0, ((int) page.getBBox().getWidth()), ((int) page.getBBox().getHeight()));
Image img = page.getImage(rect.width, rect.height, rect,
null, // null for the ImageObserver
true, // fill background with white
true // block until drawing is done
);