|
@@ -340,11 +340,13 @@ public class DocServiceImpl extends ServiceImpl<DocDao, Doc> implements DocServi
|
|
|
log.info("pdfDetail--文件路径:{}", path + filePath);
|
|
|
log.info("createPath---路径:{}", createPath);
|
|
|
// 生成图片
|
|
|
- int pageSize = PdfUtil.toImages(createPath);
|
|
|
- LinkedList<String> images = new LinkedList<>();
|
|
|
- if (pageSize > 0) {
|
|
|
- for (int i = 1; i <= pageSize; i++) {
|
|
|
- images.add(path + imageFilePath + i + ".png");
|
|
|
+ LinkedList<String> images = getPdfImages(createPath, path + imageFilePath);
|
|
|
+ if (images.size() == 0) {
|
|
|
+ int pageSize = PdfUtil.toImages(createPath);
|
|
|
+ if (pageSize > 0) {
|
|
|
+ for (int i = 1; i <= pageSize; i++) {
|
|
|
+ images.add(path + imageFilePath + i + ".png");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
PdfDetailResponse rs = new PdfDetailResponse();
|
|
@@ -641,4 +643,20 @@ public class DocServiceImpl extends ServiceImpl<DocDao, Doc> implements DocServi
|
|
|
}
|
|
|
return message;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public LinkedList<String> getPdfImages(String pdfPath, String parentPath) {
|
|
|
+ LinkedList<String> images = new LinkedList<>();
|
|
|
+ File imagesDirectory = new File(pdfPath.substring(0, pdfPath.lastIndexOf('.')));
|
|
|
+ if (imagesDirectory.exists()) {
|
|
|
+ File[] files = imagesDirectory.listFiles();
|
|
|
+ if (null != files && files.length > 0) {
|
|
|
+ for (int i = 1; i <= files.length; i++) {
|
|
|
+ images.add(parentPath + i + ".png");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return images;
|
|
|
+ }
|
|
|
+
|
|
|
}
|