|
@@ -1,11 +1,5 @@
|
|
package org.springblade.business.utils;
|
|
package org.springblade.business.utils;
|
|
|
|
|
|
-import cfca.com.itextpdf.text.Document;
|
|
|
|
-import cfca.com.itextpdf.text.pdf.PdfCopy;
|
|
|
|
-import cfca.com.itextpdf.text.pdf.PdfReader;
|
|
|
|
-import org.springblade.common.utils.CommonUtil;
|
|
|
|
-
|
|
|
|
-import java.io.FileOutputStream;
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
public class FileUtils {
|
|
public class FileUtils {
|
|
@@ -14,44 +8,44 @@ public class FileUtils {
|
|
* 合并方法
|
|
* 合并方法
|
|
*/
|
|
*/
|
|
public static void mergePdfPublicMethods(List<String> urlList, String localImgUrl){
|
|
public static void mergePdfPublicMethods(List<String> urlList, String localImgUrl){
|
|
- PdfReader reader = null;
|
|
|
|
-
|
|
|
|
- Document doc = new Document();
|
|
|
|
- PdfCopy pdfCopy = null;
|
|
|
|
- try{
|
|
|
|
- pdfCopy = new PdfCopy(doc, new FileOutputStream(localImgUrl));
|
|
|
|
- int pageCount;
|
|
|
|
- doc.open();
|
|
|
|
-
|
|
|
|
- for(String urlStr : urlList){
|
|
|
|
- try{
|
|
|
|
- //获取OSS文件输入流
|
|
|
|
- reader = new PdfReader(CommonUtil.getOSSInputStream(urlStr));
|
|
|
|
-
|
|
|
|
- pageCount = reader.getNumberOfPages();
|
|
|
|
-
|
|
|
|
- for(int i = 0; i < pageCount; ++i){
|
|
|
|
- int is = i + 1;
|
|
|
|
- pdfCopy.addPage(pdfCopy.getImportedPage(reader,is));
|
|
|
|
- }
|
|
|
|
- }catch (Exception e){
|
|
|
|
- e.printStackTrace();
|
|
|
|
- } finally {
|
|
|
|
- if(reader != null){
|
|
|
|
- reader.close();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }catch (Exception e){
|
|
|
|
- e.printStackTrace();
|
|
|
|
- } finally {
|
|
|
|
- if(pdfCopy != null){
|
|
|
|
- pdfCopy.flush();
|
|
|
|
- pdfCopy.close();
|
|
|
|
- }
|
|
|
|
- doc.close();
|
|
|
|
- }
|
|
|
|
|
|
+// PdfReader reader = null;
|
|
|
|
+//
|
|
|
|
+// Document doc = new Document();
|
|
|
|
+// PdfCopy pdfCopy = null;
|
|
|
|
+// try{
|
|
|
|
+// pdfCopy = new PdfCopy(doc, new FileOutputStream(localImgUrl));
|
|
|
|
+// int pageCount;
|
|
|
|
+// doc.open();
|
|
|
|
+//
|
|
|
|
+// for(String urlStr : urlList){
|
|
|
|
+// try{
|
|
|
|
+// //获取OSS文件输入流
|
|
|
|
+// reader = new PdfReader(CommonUtil.getOSSInputStream(urlStr));
|
|
|
|
+//
|
|
|
|
+// pageCount = reader.getNumberOfPages();
|
|
|
|
+//
|
|
|
|
+// for(int i = 0; i < pageCount; ++i){
|
|
|
|
+// int is = i + 1;
|
|
|
|
+// pdfCopy.addPage(pdfCopy.getImportedPage(reader,is));
|
|
|
|
+// }
|
|
|
|
+// }catch (Exception e){
|
|
|
|
+// e.printStackTrace();
|
|
|
|
+// } finally {
|
|
|
|
+// if(reader != null){
|
|
|
|
+// reader.close();
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// }catch (Exception e){
|
|
|
|
+// e.printStackTrace();
|
|
|
|
+// } finally {
|
|
|
|
+// if(pdfCopy != null){
|
|
|
|
+// pdfCopy.flush();
|
|
|
|
+// pdfCopy.close();
|
|
|
|
+// }
|
|
|
|
+// doc.close();
|
|
|
|
+// }
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|