Aspose.Words for Java是功能丰富的Word处理API,允许开发人员在不使用Microsoft Word的情况下嵌入在自己的Java应用程序中生成,修改,转换,呈现和打印文档的功能。同时还提供访问和操作所有文档元素的格式属性,高质量转换为多种格式,将单个页面或完整文档呈现为不同文件格式,使用来自各种数据源或业务对象的数据生成报告等功能。
Aspose.Words for Java(点击下载)更新至新版本v19.9,新增基于HarfBuzz整形器的高级排版以及简化Java上的XML数据源使用,添加对Truncate字体高度兼容性选项的支持,修复多项Bug,我们一起来看一看新功能详解吧!
主要特点
- 添加基于HarfBuzz整形器的高级排版
- 提供了用于编写和修改VBA宏的API
- 实现了创建重复节结构化文档标签的能力
- 简化了LINQ Reporting Engine的XML和CSV数据源的工作
- 改进了“Sitka Banner”、“Sitka Display”、“Sitka Heading”、“Sitka Small”、“Sitka Subheading”、“Sitka Text”和“Cambria Math”字体的渲染
- 实现OpenType数字间距
新功能示例
▲WORDSNET-12655 - 实现了创建重复节结构化文档标签的能力
新版本可以创建重复节的结构化文档标记节点和重复节项类型。新项目也已添加到SdtType枚举类型中:
public enum SdtType
{
…
////// The SDT represents repeating section item.
///////// This is MS-specific feature available since Office 2013 and not supported by the ISO/IEC 29500 OOXML standard.
///RepeatingSectionItem,
…
}
用例创建映射到自定义XML部分的表重复节:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
CustomXmlPart xmlPart = doc.CustomXmlParts.Add("Books",
"Everyday ItalianGiada De Laurentiis" +
"Harry PotterJ K. Rowling" +
"Learning XMLErik T. Ray");
Table table = builder.StartTable();
builder.InsertCell();
builder.Write("Title");
builder.InsertCell();
builder.Write("Author");
builder.EndRow();
builder.EndTable();
StructuredDocumentTag repeatingSectionSdt =
new StructuredDocumentTag(doc, SdtType.RepeatingSection, MarkupLevel.Row);
repeatingSectionSdt.XmlMapping.SetMapping(xmlPart, "/books[1]/book", "");
table.AppendChild(repeatingSectionSdt);
StructuredDocumentTag repeatingSectionItemSdt =
new StructuredDocumentTag(doc, SdtType.RepeatingSectionItem, MarkupLevel.Row);
repeatingSectionSdt.AppendChild(repeatingSectionItemSdt);
Row row = new Row(doc);
repeatingSectionItemSdt.AppendChild(row);
StructuredDocumentTag titleSdt =
new StructuredDocumentTag(doc, SdtType.PlainText, MarkupLevel.Cell);
titleSdt.XmlMapping.SetMapping(xmlPart, "/books[1]/book[1]/title[1]", "");
row.AppendChild(titleSdt);
StructuredDocumentTag authorSdt =
new StructuredDocumentTag(doc, SdtType.PlainText, MarkupLevel.Cell);
authorSdt.XmlMapping.SetMapping(xmlPart, "/books[1]/book[1]/author[1]", "");
row.AppendChild(authorSdt);
doc.Save(dir + "Document.docx");
来源:oschina
链接:https://my.oschina.net/u/4087915/blog/3106566