93k的word文档被转换成2.6m

由于文件由93K被转换成了2.6M导致在WEB项目中打开非常缓慢,以下附件中是源文件,核心源代码如下:

HtmlFixedSaveOptions saveOptions = new HtmlFixedSaveOptions();
try {
saveOptions.setShowPageBorder(false);
saveOptions.setPrettyFormat(true);
saveOptions.setExportEmbeddedCss(true);
saveOptions.setExportEmbeddedFonts(true);
saveOptions.setExportEmbeddedImages(true);
saveOptions.setExportEmbeddedSvg(true);
saveOptions.setWarningCallback(new IWarningCallback() {
@Override
public void warning(WarningInfo warningInfo) {
if (WarningType.FONT_EMBEDDING == warningInfo.getWarningType()
|| WarningType.FONT_SUBSTITUTION == warningInfo.getWarningType()) {
ConverterLogger.logInfo(getClass(), warningInfo.getDescription());
}
}
});
for (Field field : word.getRange().getFields()) {
if (FieldType.FIELD_HYPERLINK == field.getType()) {
((FieldHyperlink) field).setTarget("_blank");
}
}
saveOptions.setUpdateFields(false);
} catch (Throwable throwable) {
if (throwable instanceof ThreadDeath || throwable instanceof OutOfMemoryError) {
throw throwable;
} else {
throw new Exception(“aspose_setting”, throwable);
}
}
int htmlPageCount = 0;
try {
htmlPageCount = word.getPageCount();
viewerParam.put(“htmlPageCount”, htmlPageCount);
} catch (Throwable throwable) {
if (throwable instanceof ThreadDeath || throwable instanceof OutOfMemoryError) {
throw throwable;
} else {
throw new Exception(“aspose_getPageCount”, throwable);
}
}
String pageKey = “page-”;
IConvertFile pageConvertFile = null;
OutputStream pageConvertStream = null;
for (int i = 1; i <= htmlPageCount; i++) {
try {
ConverterLogger.logDebug(getClass(), “文件-” + sourceFile.getFileName() + “-第” + i + “页转换HTML开始:\n”);
saveOptions.setPageIndex(i - 1);
saveOptions.setPageCount(1);
try {
pageConvertFile = sourceFile.newConvertFile(pageKey + i + “-svg”);
pageConvertStream = pageConvertFile.getOutputStream();
} catch (Throwable throwable) {
if (throwable instanceof ThreadDeath || throwable instanceof OutOfMemoryError) {
throw throwable;
} else {
throw new Exception(“createConvertFile”, throwable);
}
}
try {
word.save(pageConvertStream, saveOptions);
} catch (Throwable throwable) {
if (throwable instanceof ThreadDeath || throwable instanceof OutOfMemoryError) {
throw throwable;
} else {
throw new Exception(“aspose_convert”, throwable);
}
}
ConverterLogger.logDebug(getClass(), “文件-” + sourceFile.getFileName() + “-第” + i + “页转换HTML结束:\n”);
} catch (Throwable throwable) {
throw throwable;
} finally {
if (pageConvertStream != null) {
try {
pageConvertStream.close();
} catch (Exception e) {
//
}
}
System.gc();
}
}

您好!

此问题已反馈技术团队,一旦有结果将会反馈给您!

您好!

该问题经研发团队核实并已登记安排修改,一旦完成,将会及时通知到您。对你造成不便,请多谅解。

您好!

我们已经使用Aspose.Words for Java 17.3测试了这种场景,并注意到上报的问题。我们已在问题跟踪系统中记录了以便进一步分析和纠正。问题编号:WORDSJAVA-1519。 一旦解决,我们会通知您。