|
|
@@ -1,7 +1,6 @@
|
|
|
package com.kingdee.eas.custom.compensation.utils;
|
|
|
|
|
|
import com.kingdee.bos.BOSException;
|
|
|
-import org.apache.pdfbox.Loader;
|
|
|
import org.apache.pdfbox.contentstream.operator.Operator;
|
|
|
import org.apache.pdfbox.cos.COSArray;
|
|
|
import org.apache.pdfbox.cos.COSName;
|
|
|
@@ -40,7 +39,8 @@ public class PDFUtil {
|
|
|
ByteArrayOutputStream bos = null;
|
|
|
try {
|
|
|
//通过文件名加载文档
|
|
|
- document = Loader.loadPDF(file);
|
|
|
+ document = PDDocument.load(file);
|
|
|
+ //document = Loader.loadPDF(file);
|
|
|
bos = new ByteArrayOutputStream();
|
|
|
PDPageTree pages = document.getPages();
|
|
|
Iterator<PDPage> iter = pages.iterator();
|
|
|
@@ -79,7 +79,9 @@ public class PDFUtil {
|
|
|
//替换pdf文本内容
|
|
|
public static void replaceText(PDPage page, String searchString, String replacement) throws IOException {
|
|
|
PDFStreamParser parser = new PDFStreamParser(page);
|
|
|
- List<?> tokens = parser.parse();
|
|
|
+ parser.parse();
|
|
|
+ List<?> tokens = parser.getTokens();
|
|
|
+ //List<?> tokens = parser.parse();
|
|
|
|
|
|
// 遍历解析后的PDF操作符和对象,查找并替换文本内容
|
|
|
for (int j = 0; j < tokens.size(); j++) {
|