Spire.Doc for Java 14.7.0 现已正式发布。该版本新增了 CompareOptions 类的配置选项,并支持“双行合一”功能。此外,一些在转换 Word 到 PDF 和 HTM 时出现的问题也已经成功被修复。详情如下。
新功能:
- 文档对比功能效果进行了整体优化,在 CompareOptions 类中新增了 setIgnoreFields 和 setIgnoreCaseChanges 选项。同时将 setIgnoreTable(boolean value) 修改为 setIgnoreTables(boolean value),getIgnoreTable() 修改为 getIgnoreTables()。
- 支持“双行合一”功能。
Document doc1 = ConvertUtil.GetNewEngineDocument();
doc1.loadFromFile(inputFile_1);
String[] name1 = new String[]{"DJG_Black_Book", "DJG_Repairs_Expense", "DJG_Sale_Amount", "DJG_Dealer_Payment", "DJG_Auction_Fees"};
String[] value1 = new String[]{"20,000.00", "2,000.00", "13,500.00", "1,000.00", "500.00"};
doc1.getMailMerge().execute(name1, value1);
doc1.isUpdateFields(true);
Document doc2 = ConvertUtil.GetNewEngineDocument();
doc2.loadFromFile(inputFile_2);
String[] name2 = new String[]{"DJG_Black_Book", "DJG_Repairs_Expense", "DJG_Sale_Amount", "DJG_Dealer_Payment", "DJG_Auction_Fees"};
String[] value2 = new String[]{"50,000.00", "5,000.00", "3,500.00", "1,000.00", "200.00"};
doc2.getMailMerge().execute(name2, value2);
doc2.isUpdateFields(true);
CompareOptions options = new CompareOptions();
options.setCompareMoves(true);
options.setIgnoreCaseChanges(true);
options.setIgnoreComments(true);
options.setIgnoreFields(true);
options.setIgnoreFootnotes(true);
options.setIgnoreTables(true);
options.setIgnoreTextboxes(true);
doc1.compare(doc2, "user", new Date(), options);
doc1.saveToFile(outputFile, FileFormat.Docx_2013);
doc1.close();
doc2.close();
Document doc = ConvertUtil.GetNewEngineDocument();
Section section = doc.addSection();
section.setTextDirection(TextDirection.Right_To_Left);
Paragraph titlePara = section.addParagraph();
titlePara.appendText("===== FarEastLayout Two-Lines-in-One Full Scenario Test =====\n\n");
titlePara.appendText("\n\n1. Basic Two-Lines-in-One: ");
// Basic Two-Lines-in-One Combine=true, no brackets, no vertical layout
Paragraph p1 = section.addParagraph();
TextRange farEastLayout = p1.appendText("Basic Two-Lines-in-One: One Two Three Four");
farEastLayout.getCharacterFormat().setFontSize(12);
farEastLayout.getCharacterFormat().setFontNameFarEast("Songti");
FarEastLayout layout1 = new FarEastLayout();
layout1.setCombine(true); // Two-Lines-in-One
farEastLayout.getCharacterFormat().setFarEastLayout(layout1);
// Two-Lines-in-One + various bracket styles
Paragraph p1Title = section.addParagraph();
p1Title.appendText("\n\n2. Two-Lines-in-One + Different Brackets: ");
for (CombineBrackets bracket : CombineBrackets.values()) {
Paragraph pTmp = section.addParagraph();
TextRange rt = pTmp.appendText("Bracket Type " + bracket.name() + ": A B C D");
rt.getCharacterFormat().setFontSize(12);
rt.getCharacterFormat().setFontNameFarEast("Songti");
FarEastLayout layoutTmp = new FarEastLayout();
layoutTmp.setCombine(true);
layoutTmp.setCombineBrackets(bracket);
rt.getCharacterFormat().setFarEastLayout(layoutTmp);
}
doc.saveToFile(outputFile, FileFormat.Docx);
doc.close();
问题修复:
- 修复了比较文档报 "StrinqIndexOutofBoundsException" 的问题。
- 修复了接受修订后,表格格式错乱的问题。
- 修复了 Word 转 PDF,内容布局不一致的问题。
- 修复了合并 Word 文档,用 WPS 工具打开效果不正确的问题。
- 修复了 Word 转 HTML,表格布局不正确的问题。
- 修复了 ubuntu 环境 Word 转 PDF,图片不正确的问题。
- 修复了 Word 转 PDF,字体效果不正确的问题 。
- 修复了高版本 Java 下打包项目报错的问题。
获取 Spire.Doc for Java 14.7.0 请点击:







