fix:
1.word文档书签处理
This commit is contained in:
parent
78f3330522
commit
312f208205
@ -112,7 +112,7 @@ public class SalesOrderAutoSignOp extends AbstractOperationServicePlugIn {
|
||||
InputStream validatorStream = new ByteArrayInputStream(out.toByteArray());
|
||||
|
||||
// 获取书签
|
||||
List<CTBookmark> bookMarks = ContactSignUtils.getFileBookMarks(validatorStream);
|
||||
List<CTBookmark> bookMarks = ContactSignUtils.getFileBookMarks(validatorStream, filename);
|
||||
validatorSignAble(bookMarks, BOOKMARK, filename);
|
||||
|
||||
File file;
|
||||
|
@ -86,7 +86,7 @@ public class SalescontracValidetor extends AbstractValidator {
|
||||
InputStream validatorStream = new ByteArrayInputStream(out.toByteArray());
|
||||
|
||||
// 获取书签
|
||||
List<CTBookmark> bookMarks = ContactSignUtils.getFileBookMarks(validatorStream);
|
||||
List<CTBookmark> bookMarks = ContactSignUtils.getFileBookMarks(validatorStream, filename);
|
||||
for (CTBookmark bookMark : bookMarks) {
|
||||
String bookMarkName = bookMark.getName();
|
||||
if (bookMarkName.contains(BOOKMARK)) {
|
||||
|
@ -116,7 +116,7 @@ public class SalesOrderAutoSignOp extends AbstractOperationServicePlugIn {
|
||||
InputStream validatorStream = new ByteArrayInputStream(out.toByteArray());
|
||||
|
||||
// 获取书签
|
||||
List<CTBookmark> bookMarks = ContactSignUtils.getFileBookMarks(validatorStream);
|
||||
List<CTBookmark> bookMarks = ContactSignUtils.getFileBookMarks(validatorStream, filename);
|
||||
validatorSignAble(bookMarks, BOOKMARK, filename);
|
||||
|
||||
File file;
|
||||
|
@ -83,7 +83,7 @@ public class SalesOrderSignatureValidetor extends AbstractValidator {
|
||||
InputStream validatorStream = new ByteArrayInputStream(out.toByteArray());
|
||||
|
||||
// 获取书签
|
||||
List<CTBookmark> bookMarks = ContactSignUtils.getFileBookMarks(validatorStream);
|
||||
List<CTBookmark> bookMarks = ContactSignUtils.getFileBookMarks(validatorStream,filename);
|
||||
for (CTBookmark bookMark : bookMarks) {
|
||||
String bookMarkName = bookMark.getName();
|
||||
if (bookMarkName.contains(BOOKMARK)) {
|
||||
|
@ -7,6 +7,7 @@ import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
import org.apache.poi.util.Units;
|
||||
import org.apache.poi.xwpf.usermodel.*;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBookmark;
|
||||
@ -27,15 +28,31 @@ import java.util.*;
|
||||
public class ContactSignUtils {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ContactSignUtils.class);
|
||||
|
||||
public static List<CTBookmark> getFileBookMarks(InputStream in) {
|
||||
//<?php
|
||||
// echo readfile('.doc')
|
||||
// ?>
|
||||
public static List<CTBookmark> getFileBookMarks(InputStream in, String filename) {
|
||||
List<CTBookmark> list = new ArrayList<>();
|
||||
try (XWPFDocument doc = new XWPFDocument(in)) {
|
||||
for (XWPFParagraph paragraph : doc.getParagraphs()) {
|
||||
list.addAll(paragraph.getCTP().getBookmarkStartList());
|
||||
int lastIndexOf = filename.lastIndexOf(".");
|
||||
String extension = "";
|
||||
if (lastIndexOf>0) {
|
||||
extension = filename.substring(lastIndexOf + 1);
|
||||
}
|
||||
if ("docx".equals(extension)) {
|
||||
try (XWPFDocument doc = new XWPFDocument(in)) {
|
||||
for (XWPFParagraph paragraph : doc.getParagraphs()) {
|
||||
list.addAll(paragraph.getCTP().getBookmarkStartList());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}else if ("doc".equals(extension)){
|
||||
try (POIFSFileSystem doc = new POIFSFileSystem(in)){//HWPFDocument
|
||||
for (int i = 0; i < doc.getBigBlockSize(); i++) {
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user