Commit 08b93ec1 by guanguan1009

修改

parent 75e2c147
......@@ -93,7 +93,11 @@ public class Pdf2Pptx {
executorService.execute(new PdfTask(allot.get(String.valueOf(i)), path));
}
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
logger.error("错误:{}", e);
}
while (exeFlag) {
if (((ThreadPoolExecutor) executorService).getActiveCount() == 0) {
executorService.shutdown();
......@@ -104,7 +108,12 @@ public class Pdf2Pptx {
}
long endTime = System.currentTimeMillis();
logger.info("总耗时:{}ms", endTime - startTime);
//删除图片文件夹
//删除所有生成的图片文件
for (String dirPathName : allDirPathName) {
if (dirPathName.endsWith("_图片") && FileUtil.delFolder(dirPathName)) {
logger.info("删除文件夹:{}及其文件成功", dirPathName);
}
}
}
......@@ -138,6 +147,14 @@ public class Pdf2Pptx {
public static void main(String[] args) {
//读取指定文件夹下所有文件并转换为图片
// conver(Constant.SOURCE_PATH);
//删除所有生成的图片文件
List<String> allDirPathName = new ArrayList<>();
FileUtil.getAllDirPathNameRe(Constant.SOURCE_PATH, allDirPathName);
for (String dirPathName : allDirPathName) {
if (dirPathName.endsWith("_图片") && FileUtil.delFolder(dirPathName)) {
logger.info("删除文件夹:{}及其文件成功", dirPathName);
}
}
}
}
......@@ -40,7 +40,7 @@ public class MyTask implements Runnable {
imgFilePath.append(String.valueOf(i + 1));
imgFilePath.append(".png");
File dstFile = new File(imgFilePath.toString());
BufferedImage image = renderer.renderImageWithDPI(i, 300);
BufferedImage image = renderer.renderImageWithDPI(i, 250);
logger.info("线程:{} 开始转换第{}页pdf", Thread.currentThread().getName(), i);
ImageIO.write(image, "png", dstFile);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment