拆分中图片内容处理

This commit is contained in:
wangchengjun
2022-06-07 17:54:37 +08:00
parent 429ae2ec06
commit 73c9754540
5 changed files with 116 additions and 13 deletions
@@ -33,8 +33,11 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import sun.misc.BASE64Encoder;
import java.io.*;
import java.net.InetAddress;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -1220,19 +1223,12 @@ public class FileSpiltService {
// 处理段落生成编号不识别问题
String paragraphString = p.getText();
if (StringUtils.isNotBlank(paragraphString)) {
if (!StringUtils.isEmpty(paragraphString)) {
paragraphString = paragraphString.replace((char) 12288, ' ');
paragraphString = paragraphString.replaceAll("\r\n","");
paragraphString = paragraphString.replaceAll("\n","");
paragraphString = paragraphString.trim();
}
if(StringUtils.isEmpty(paragraphString)){
continue;
}
paragraphString = paragraphString.replaceAll("\r\n","");
paragraphString = paragraphString.replaceAll("\n","");
paragraphString = paragraphString.trim();
if(StringUtils.isEmpty(paragraphString)){
continue;
}
// if (StringUtils.isNotEmpty(p.getNumLevelText())&& p.getNumLevelText().indexOf(".")>0) {
// String numberParent = p.getNumLevelText().substring(0,p.getNumLevelText().lastIndexOf("."));
// if (numberMap.containsKey(numberParent)){
@@ -2570,13 +2566,16 @@ public class FileSpiltService {
try {
FileOutputStream fos = new FileOutputStream(filepathandname);
fos.write(bytev);
String path = splitUrl + "/" + imageName;
// String fileUrl = splitUrl + "/" + filepathandname;
BASE64Encoder base64Encoder = new BASE64Encoder();
String encode = base64Encoder.encode(filepathandname.getBytes(StandardCharsets.UTF_8));
String path = splitUrl+"/jero-boot/sys/split/file/getImage?fileUrl="+encode;
String imgCon = path;
String imgConVal = "<img class=\'wordImg\' src=\'" + path + "\'>";
message.getItemsCondi().add(imgConVal);
message.setItermsConditions(message.getItermsConditions() + imgConVal);
itemsValList.add(getSplitItemsValObject(message.getId(), SplitFilePragraTypeEnum.IMG.getValue(), imgCon, message.getItemsCondi().size(), null));
} catch (IOException e) {
} catch (Exception e) {
e.printStackTrace();
}
}