案例:有个小需求,批量处理大量PDF文件,处理封面信息,生成一个新的Excel用来统计,PDF文件封面如下图图1,生成Excel如下图图2。
解决:
1、获取本地路径下的所有待处理的pdf文件
private static LinkedList<File> getPDFList(String pathName) {
File file = new File(pathName);
LinkedList<File> list = new LinkedList<>();
LinkedList<File> pdfList = new LinkedList<File>();
if (file.exists()) {
if (null == file.listFiles()) {
if (file.getAbsolutePath().endsWith(".pdf")) pdfList.add(file);
} else {
list.addAll(Arrays.asList(file.listFiles()));
while (!list.isEmpty()) {