fix 文档拆分--公式

This commit is contained in:
lijiarao
2024-01-25 13:58:54 +08:00
parent 15c8da599d
commit 6fa3678595
5 changed files with 114 additions and 50 deletions
+2 -2
View File
@@ -165,10 +165,10 @@
<artifactId>jeuclid-core</artifactId>
<version>3.1.9</version>
</dependency>
<dependency>
<!--<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.17</version>
</dependency>
</dependency>-->
</dependencies>
</project>
@@ -26,6 +26,7 @@ import org.apache.shiro.SecurityUtils;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlObject;
import org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObject;
import org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtension;
import org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture;
import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTAnchor;
import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline;
@@ -154,17 +155,17 @@ public class FileSpiltService {
ZipSecureFile.setMinInflateRatio(-1.0d);
XWPFDocument doc = new XWPFDocument(is);
// 获取文档中的图片
//List<XWPFPictureData> allPictures = doc.getAllPictures();
//// 遍历图片并处理数学公式
//for (XWPFPictureData pictureData : allPictures) {
// String contentType = pictureData.getPackagePart().getContentType();
// System.out.println(contentType);
// // 判断图片类型是否为数学公式
// if (contentType.equals(PictureType.EMF.getExtension())) {
// // 处理数学公式,你可以在这里添加自己的逻辑
// System.out.println("Found a math equation!");
// }
//}
List<XWPFPictureData> allPictures = doc.getAllPictures();
// 遍历图片并处理数学公式
for (XWPFPictureData pictureData : allPictures) {
String contentType = pictureData.getPackagePart().getContentType();
System.out.println(contentType);
// 判断图片类型是否为数学公式
if (contentType.equals(PictureType.EMF.getExtension())) {
// 处理数学公式,你可以在这里添加自己的逻辑
System.out.println("Found a math equation!");
}
}
//获得序号标题和无标题序号
TitleNumberVO titleNumberVO = AsposeUtil.getNumber(is1);
//TitleNumberVO titleNumberVO = new TitleNumberVO();
@@ -200,16 +201,16 @@ public class FileSpiltService {
CTOMath ctoMath = (CTOMath) child;
//stringBuilder.append(ctoMath.xmlText());
// 处理word中存在的公式成mathML格式
String imageName = OmmlUtils.convertOmathToPng(ctoMath.xmlText());
if (messageList.size() > 0) {
addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, imageName);
}
//String imageName = OmmlUtils.convertOmathToPng(ctoMath.xmlText());
//if (messageList.size() > 0) {
// addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, imageName);
//}
} else if (child instanceof CTOMathPara) {
CTOMathPara ctoMathPara = (CTOMathPara) child;
String imageName = OmmlUtils.convertOmathToPng(ctoMathPara.xmlText());
if (messageList.size() > 0) {
addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, imageName);
}
//String imageName = OmmlUtils.convertOmathToPng(ctoMathPara.xmlText());
//if (messageList.size() > 0) {
// addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, imageName);
//}
}
}
@@ -23,13 +23,8 @@ public class ImageParse {
super();
// this.targetDir = targetDir;
}
public String parse(byte[] data, String extName) {
String imageName = UUIDUtils.randomUUID10() + extName;
String filepathandname = filePathCos + "/" + imageName;
MinioUtil.uploadByte(data, filepathandname);
return imageName;
return parse(new ByteArrayInputStream(data), extName);
}
public String parse(InputStream in, String extName) {
@@ -50,5 +45,17 @@ public class ImageParse {
return filename;
}
//public String parse(byte[] data, String extName) {
// String imageName = UUIDUtils.randomUUID10() + extName;
//
// String filepathandname = filePathCos + "/" + imageName;
// MinioUtil.uploadByte(data, filepathandname);
// return imageName;
//}
}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long