六月已至,.NET版Aspose.Words也为大家带来了6月的新版本!Aspose.Words for .Net是一种高级Word文档处理API,用于执行各种文档管理和操作任务。API支持生成,修改,转换,呈现和打印文档,而无需在跨平台应用程序中直接使用Microsoft Word。
主要特点如下:
- Font.EmphasisMark向公众公开
- 添加了新的公共属性ImportFormatOptions.IgnoreHeaderFooter
- 引入了MarkdownSaveOptions类
- 提供了用于控制LINQ Reporting Engine的JSON简单值识别的选项
>>你可以点击文末“了解更多”下载Aspose.Words for .NET v20.6测试体验
具体更新内容
WORDSNET-13983 添加功能以支持“标记上的强调”字体设置 新功能
WORDSNET-19976 字体嵌入效果很好,但是符号未正确保存到PDF 新功能
WORDSNET-20513 检查Aspose.Words for .NET如何与.NET 5.0一起使用 新功能
WORDSNET-20488 LINQ Reporting Engine-提供一种使用JsonDataSource的准确格式解析日期时间值的方法 新功能
WORDSNET-19979 LINQ Reporting Engine-提供一种模式,可根据JSON表示法本身确定JSON简单值的类型 新功能
WORDSNET-20297 添加使用SaveOptions创建MarkdownSaveOptions的功能 新功能
WORDSNET-20491 加载PDF时发生System.IO.FileLoadException 增强功能
WORDSNET-20492 PDF到Word的转换,有时在新页面上重复行 增强功能
公共API更改
①添加了新的公共类MarkdownSaveOptions
/// <summary>
/// Class to specify additional options when saving a document into the <see cref="Words.SaveFormat.Markdown"/> format.
/// </summary>
public class MarkdownSaveOptions : TxtSaveOptionsBase
暂时只有以下几个公共API:
/// <summary>
/// Specifies the format in which the document will be saved if this save options object is used.
/// Can only be <see cref="Words.SaveFormat.Markdown"/>.
/// </summary>
public override SaveFormat SaveFormat
注意,将TxtSaveOptionsBase.PreserveTableLayout移至TxtSaveOptions.PreserveTableLayout:
/// <summary>
/// Specifies whether the program should attempt to preserve layout of tables when saving in the plain text format.
/// The default value is <b>false</b>.
/// </summary>
public bool PreserveTableLayout
用例。说明如何创建和使用MarkdownSaveOptions对象:
DocumentBuilder builder = new DocumentBuilder();
builder.Writeln("Some text!");
MarkdownSaveOptions saveOptions = (MarkdownSaveOptions)SaveOptions.CreateSaveOptions(SaveFormat.Markdown);
builder.Document.Save("TestDocument.md", saveOptions);
②添加了新的公共属性Font.EmphasisMark
/// <summary>
/// Gets or sets the emphasis mark applied to this formatting.
/// </summary>
public EmphasisMark EmphasisMark
强调标记是一个附加字符,它在下面的枚举中指定的主字符字形之上或之下呈现。
/// <summary>
/// Specifies possible types of emphasis mark.
/// </summary>
/// <dev>
/// Names borrowed from https://docs.microsoft.com/en-us/dotnet/api/microsoft.office.interop.word.wdemphasismark?view=word-pia
/// </dev>
public enum EmphasisMark
{
/// <summary>
/// No emphasis mark.
/// </summary>
None = 0x00,
/// <summary>
/// Emphasis mark is a solid black circle displayed above text.
/// </summary>
OverSolidCircle = 0x01,
/// <summary>
/// Emphasis mark is a comma character displayed above text.
/// </summary>
OverComma = 0x02,
/// <summary>
/// Emphasis mark is an empty white circle displayed above text.
/// </summary>
OverWhiteCircle = 0x03,
/// <summary>
/// Emphasis mark is a solid black circle displayed below text.
/// </summary>
UnderSolidCircle = 0x04,
}
用例。说明如何通过DocumentBuilder设置Font.EmphasisMark:
Document document = new Document();
DocumentBuilder builder = new DocumentBuilder(document);
builder.Font.EmphasisMark = EmphasisMark.UnderSolidCircle;
builder.Write("Emphasis text");
builder.Writeln();
builder.Font.ClearFormatting();
builder.Write("Simple text");
document.Save(savePath, saveOptions);
③添加了新的公共属性ImportFormatOptions.IgnoreHeaderFooter
/// <summary>
/// Gets or sets a boolean value that specifies that source formatting of headers/footers content ignored
/// if ImportFormatMode.KeepSourceFormatting mode is used.
/// The default value is true.
/// </summary>
默认情况下,保留Word的行为是对的。用例:
Document dstDocument = new Document(dstDocumentPath);
Document srcDocument = new Document(srcDocumentPath);
ImportFormatOptions importFormatOptions = new ImportFormatOptions();
importFormatOptions.IgnoreHeaderFooter = false;
dstDocument.AppendDocument(srcDocument, ImportFormatMode.KeepSourceFormatting, importFormatOptions);;
④添加了新的公共属性MarkdownSaveOptions.TableContentAlignment
/// <summary>
/// Gets or sets a value that specifies how to align contents in tables
/// when exporting into the <see cref="Words.SaveFormat.Markdown"/> format.
/// The default value is <see cref="Saving.TableContentAlignment.Auto"/>.
/// </summary>
public TableContentAlignment TableContentAlignment { get; set; }
此外,还添加了一个新的公共枚举:
/// <summary>
/// Allows to specify the alignment of the content of the table to be used when exporting into Markdown format.
/// </summary>
public enum TableContentAlignment
{
/// <summary>
/// The alignment will be taken from the first paragraph in corresponding table column.
/// </summary>
Auto,
/// <summary>
/// The content of tables will be aligned to the Left.
/// </summary>
Left,
/// <summary>
/// The content of tables will be aligned to the Center.
/// </summary>
Center,
/// <summary>
/// The content of tables will be aligned to the Right.
/// </summary>
Right
}
用例。说明导出到Markdown时如何在表格内对齐内容:
MarkdownSaveOptions saveOptions = new MarkdownSaveOptions();
// Makes all paragraphs inside table to be aligned to Left.
saveOptions.TableContentAlignment = TableContentAlignment.Left;
builder.Document.Save("left.md", saveOptions);
// Makes all paragraphs inside table to be aligned to Right.
saveOptions.TableContentAlignment = TableContentAlignment.Right;
builder.Document.Save("right.md", saveOptions);
// Makes all paragraphs inside table to be aligned to Center.
saveOptions.TableContentAlignment = TableContentAlignment.Center;
builder.Document.Save("center.md", saveOptions);
// Makes all paragraphs inside table to be aligned automatically.
// The alignment in this case will be taken from the first paragraph in corresponding table column.
saveOptions.TableContentAlignment = TableContentAlignment.Auto;
builder.Document.Save("auto.md", saveOptions);
如果您有任何疑问或需求,请随时加入Aspose技术交流群(642018183),我们很高兴为您提供查询和咨询。
本文暂时没有评论,来添加一个吧(●'◡'●)