原创|产品更新|编辑:李显亮|2021-02-18 10:00:40.893|阅读 191 次
概述:Aspose.Words for .Net更新至新版本v21.2,此常规的每月版本中有86项改进和修复,包括9项新功能的发布,欢迎下载体验。
# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>
Aspose.Words for .Net是一种高级Word文档处理API,用于执行各种文档管理和操作任务。API支持生成,修改,转换,呈现和打印文档,而无需在跨平台应用程序中直接使用Microsoft Word。2021年2月更新来啦,.NET版Aspose.Words更新至v21.2新版本!
主要特点如下:
>>你可以点击这里下载Aspose.Words for .NET v21.2测试体验。
关键 | 概括 | 类别 |
WORDSNET-21363 | 支持为LINQ Reporting Engine动态添加组合框和下拉列表项 | 新功能 |
WORDSNET-6146 | 允许从OLE对象提取可见的纯文本 | 新功能 |
WORDSNET11848 | 添加保存选项以模仿MS Word行为或不模仿创建,修改和打印日期 | 新功能 |
WORDSNET-6125 | 添加选项以将文档中的图像导出为SVG格式的HTML | 新功能 |
WORDSNET-10148 | 提供移动到段落中特定字符的能力 | 新功能 |
WORDSNET-20863 | 在Azure上将DOCX转换为PDF时,内容控制日期会更改 | 新功能 |
WORDSNET-21639 | LegacyMode = false时,Range.Replace引发System.IndexOutOfRangeException | 新功能 |
WORDSNET-21183 | 将自定义字体样式设置为“链接到主题”字体不起作用 | 新功能 |
WORDSNET-20546 | ComHelper.Open不会使用Delphi从流中导入RTF | 新功能 |
WORDSNET-20414 | PdfDocumentReader插件镜像希伯来语文本 | 增强功能 |
WORDSNET-9605 | 支持DrawingML 3D效果的渲染 | 增强功能 |
WORDSNET-15833 | 改善在MS Word 97中创建的渲染形状线的兼容性 | 增强功能 |
WORDSNET-10441 | 支持Word 6.0 / 95的图形对象 | 增强功能 |
WORDSNET-2799 | 尝试恢复损坏的进口文件 | 增强功能 |
WORDSNET-1738 | 在保存DOCX文件期间优化内存使用 | 增强功能 |
WORDSNET-21652 | 没有将生成器名称写入XamlFixed / XamlFlow / XamlFlowPack / HtmlFixed文档 | 增强功能 |
完整更新细则请参考:【Aspose.Words for .NET v21.2更新说明】
用例如下:
Document doc = new Document(docPath); SaveOptions saveOptions = new PdfSaveOptions(); saveOptions.UpdateLastPrintedProperty = true; doc.Save(pdfPath, saveOptions);
向Font对象添加了新的公共属性:
还添加了相应的公共枚举:
用例:说明如何创建和使用主题样式。
Document doc = new Document("input.docx"); DocumentBuilder builder = new DocumentBuilder(doc); builder.MoveToDocumentEnd(); builder.Writeln(); // Create some style with theme font properties. Style style = doc.Styles.Add(StyleType.Paragraph, "ThemedStyle"); style.Font.ThemeFont = ThemeFont.Major; style.Font.ThemeColor = ThemeColor.Accent5; style.Font.TintAndShade = 0.3; builder.ParagraphFormat.StyleName = "ThemedStyle"; builder.Writeln("Text with themed style"); // Get just inserted run. Run run = (Run)((Paragraph)builder.CurrentParagraph.PreviousSibling).FirstChild; Console.WriteLine("Theme color: {0}", run.Font.ThemeColor); Console.WriteLine("Color: {0}\n", run.Font.Color); Console.WriteLine("TintAndShade: {0:N2}\n", run.Font.TintAndShade); Console.WriteLine("Theme font: {0}", run.Font.ThemeFont); Console.WriteLine("Font: {0}\n", run.Font.Name); Console.WriteLine("Theme font Ascii: {0}", run.Font.ThemeFontAscii); Console.WriteLine("Font Ascii: {0}\n", run.Font.NameAscii); Console.WriteLine("Theme font Bi: {0}", run.Font.ThemeFontBi); Console.WriteLine("Font Bi: {0}\n", run.Font.NameBi); Console.WriteLine("Theme font EastAsian: {0}", run.Font.ThemeFontFarEast); Console.WriteLine("Font EastAsian: {0}\n", run.Font.NameFarEast); Console.WriteLine("Theme font Other: {0}", run.Font.ThemeFontOther); Console.Write("Font Other: {0}", run.Font.NameOther); /* This code example produces the following results: Theme color: Accent5 Color: Color [Empty] TintAndShade: 0.30 Theme font: Major Font: Calibri Light Theme font Ascii: Major Font Ascii: Calibri Light Theme font Bi: Major Font Bi: Times New Roman Theme font EastAsian: Major Font EastAsian: Times New Roman Theme font Other: Major Font Other: Calibri Light */
用例:介绍如何通过应用主题字体“无”将非主题字体名称更改为主题字体,反之亦然。
// Create new document with themes. Document doc = new Document(); doc.Theme.MinorFonts.Latin = "Algerian"; doc.Theme.MinorFonts.EastAsian = "Aharoni"; doc.Theme.MinorFonts.ComplexScript = "Andalus"; // Check original theme font. Font font = doc.Styles["Normal"].Font; Console.WriteLine("Originally the Normal style theme font is: {0}\n", font.ThemeFont); // Apply theme font 'Minor' font.ThemeFont = ThemeFont.Minor; Console.WriteLine("'Minor' theme font is applied:"); Console.WriteLine("Theme font: {0}", font.ThemeFont); Console.WriteLine("Font: {0}\n", font.Name); Console.WriteLine("Theme font Ascii: {0}", font.ThemeFontAscii); Console.WriteLine("Font Ascii: {0}\n", font.NameAscii); Console.WriteLine("Theme font Bi: {0}", font.ThemeFontBi); Console.WriteLine("Font Bi: {0}\n", font.NameBi); Console.WriteLine("Theme font EastAsian: {0}", font.ThemeFontFarEast); Console.WriteLine("Font EastAsian: {0}\n", font.NameFarEast); Console.WriteLine("Theme font Other: {0}", font.ThemeFontOther); Console.WriteLine("Font Other: {0}\n\n", font.NameOther); // Set non-theme font. font.ThemeFont = ThemeFont.None; Console.WriteLine("'None' theme font is applied:"); Console.WriteLine("Theme font: {0}", font.ThemeFont); Console.WriteLine("Font: {0}\n", font.Name); Console.WriteLine("Theme font Ascii: {0}", font.ThemeFontAscii); Console.WriteLine("Font Ascii: {0}\n", font.NameAscii); Console.WriteLine("Theme font Bi: {0}", font.ThemeFontBi); Console.WriteLine("Font Bi: {0}\n", font.NameBi); Console.WriteLine("Theme font EastAsian: {0}", font.ThemeFontFarEast); Console.WriteLine("Font EastAsian: {0}\n", font.NameFarEast); Console.WriteLine("Theme font Other: {0}", font.ThemeFontOther); Console.Write("Font Other: {0}\n", font.NameOther); /* This code example produces the following results: Originally the Normal style theme font is: None 'Minor' theme font is applied: Theme font: Minor Font: Algerian Theme font Ascii: Minor Font Ascii: Algerian Theme font Bi: Minor Font Bi: Andalus Theme font EastAsian: Minor Font EastAsian: Aharoni Theme font Other: Minor Font Other: Algerian 'None' theme font is applied: Theme font: None Font: Algerian Theme font Ascii: None Font Ascii: Algerian Theme font Bi: None Font Bi: Andalus Theme font EastAsian: None Font EastAsian: Aharoni Theme font Other: None Font Other: Algerian */
用例:介绍如何通过应用一些简单的字体名称将非主题字体名称更改为主题字体,反之亦然。
// Create new document with themes. Document doc = new Document(); doc.Theme.MinorFonts.Latin = "Algerian"; doc.Theme.MinorFonts.EastAsian = "Aharoni"; doc.Theme.MinorFonts.ComplexScript = "Andalus"; // Check original theme font. Font font = doc.Styles["Normal"].Font; Console.WriteLine("Originally the Normal style theme font is: {0}\n", font.ThemeFont); // Apply theme font 'Minor' font.ThemeFont = ThemeFont.Minor; Console.WriteLine("'Minor' theme font is applied:"); Console.WriteLine("Theme font: {0}", font.ThemeFont); Console.WriteLine("Font: {0}\n", font.Name); Console.WriteLine("Theme font Ascii: {0}", font.ThemeFontAscii); Console.WriteLine("Font Ascii: {0}\n", font.NameAscii); Console.WriteLine("Theme font Bi: {0}", font.ThemeFontBi); Console.WriteLine("Font Bi: {0}\n", font.NameBi); Console.WriteLine("Theme font EastAsian: {0}", font.ThemeFontFarEast); Console.WriteLine("Font EastAsian: {0}\n", font.NameFarEast); Console.WriteLine("Theme font Other: {0}", font.ThemeFontOther); Console.WriteLine("Font Other: {0}\n\n", font.NameOther); // Set non-theme font name. font.Name = "Arial"; Console.WriteLine("Non-themed font name is applied:"); Console.WriteLine("Theme font: {0}", font.ThemeFont); Console.WriteLine("Font: {0}\n", font.Name); Console.WriteLine("Theme font Ascii: {0}", font.ThemeFontAscii); Console.WriteLine("Font Ascii: {0}\n", font.NameAscii); Console.WriteLine("Theme font Bi: {0}", font.ThemeFontBi); Console.WriteLine("Font Bi: {0}\n", font.NameBi); Console.WriteLine("Theme font EastAsian: {0}", font.ThemeFontFarEast); Console.WriteLine("Font EastAsian: {0}\n", font.NameFarEast); Console.WriteLine("Theme font Other: {0}", font.ThemeFontOther); Console.Write("Font Other: {0}", font.NameOther); /* This code example produces the following results: Originally the Normal style theme font is: None 'Minor' theme font is applied: Theme font: Minor Font: Algerian Theme font Ascii: Minor Font Ascii: Algerian Theme font Bi: Minor Font Bi: Andalus Theme font EastAsian: Minor Font EastAsian: Aharoni Theme font Other: Minor Font Other: Algerian Non-themed font name is applied: Theme font: None Font: Arial Theme font Ascii: None Font Ascii: Arial Theme font Bi: None Font Bi: Arial Theme font EastAsian: None Font EastAsian: Arial Theme font Other: None Font Other: Arial */
用例:说明如何通过应用主题字体颜色“无”将非主题颜色更改为主题颜色,反之亦然。
Document doc = new Document(); // Check original theme color. Font font = doc.Styles["Normal"].Font; Console.WriteLine("Originally the Normal style theme color is: {0} and RGB color is: {1}\n", font.ThemeColor, font.Color); // Apply theme color. font.ThemeColor = ThemeColor.Accent2; Console.WriteLine("'Accent2' theme color is applied:"); Console.WriteLine("Theme color: {0}", font.ThemeColor); Console.WriteLine("RGB color: {0}\n", font.Color); // Set theme color back to 'None'. font.ThemeColor = ThemeColor.None; Console.WriteLine("Theme color 'None' is applied:"); Console.WriteLine("Theme color: {0}", font.ThemeColor); Console.WriteLine("RGB color: {0}", font.Color); /* This code example produces the following results: Originally the Normal style theme color is: None and RGB color is: Color [Empty] 'Accent2' theme color is applied: Theme color: Accent2 RGB color: Color [Empty] Theme color 'None' is applied: Theme color: None RGB color: Color [Empty] */
用例:说明如何通过应用一些简单的RGB颜色将非主题字体名称更改为主题字体名称,反之亦然。
Document doc = new Document(); // Check original theme color. Font font = doc.Styles["Normal"].Font; Console.WriteLine("Originally the Normal style theme color is: {0} and RGB color is: {1}\n", font.ThemeColor, font.Color); // Apply theme color. font.ThemeColor = ThemeColor.Accent2; Console.WriteLine("'Accent2' theme color is applied:"); Console.WriteLine("Theme color: {0}", font.ThemeColor); Console.WriteLine("RGB color: {0}\n", font.Color); // Set simple RGB color. font.Color = Color.Blue; font.ThemeColor = ThemeColor.None; Console.WriteLine("RGB color is applied:"); Console.WriteLine("Theme color: {0}", font.ThemeColor); Console.WriteLine("RGB color: {0}", font.Color); /* This code example produces the following results: Originally the Normal style theme color is: None and RGB color is: Color [Empty] 'Accent2' theme color is applied: Theme color: Accent2 RGB color: Color [Empty] RGB color is applied: Theme color: None RGB color: Color [A=255, R=0, G=0, B=255] */
用例:说明如何使用Font.TintAndShade属性。
Document doc = new Document(); Font font = doc.Styles["Normal"].Font; font.ThemeColor = ThemeColor.Accent6; font.TintAndShade = -0.25; Console.WriteLine("TintAndShade is set to {0:N2}", font.TintAndShade); Console.WriteLine("Theme color: {0}", font.ThemeColor); Console.WriteLine("RGB color: {0}", font.Color); /* This code example produces the following results: TintAndShade is set to -0.25 Theme color: Accent6 RGB color: Color [Empty] */
向FindReplaceOptions对象添加了一个新的公共属性:
用例:说明如何使用SmartParagraphBreakReplacement属性。
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Create two tables with paragraph and inner table in first cell: // ┌───────────────────────┐ // │ TEXT1¶ │ // │ ┌───────────────────┐ │ // │ |¶ | | // | └───────────────────┘ │ // └───────────────────────┘ // ┌───────────────────────┐ // │ TEXT2¶ │ // │ ┌───────────────────┐ │ // │ |¶ | | // | └───────────────────┘ │ // └───────────────────────┘ builder.StartTable(); builder.InsertCell(); builder.Write("TEXT1"); builder.StartTable(); builder.InsertCell(); builder.EndTable(); builder.EndTable(); builder.Writeln(); builder.StartTable(); builder.InsertCell(); builder.Write("TEXT2"); builder.StartTable(); builder.InsertCell(); builder.EndTable(); builder.EndTable(); builder.Writeln(); FindReplaceOptions options = new FindReplaceOptions(); // When the following option is set to 'true', // Aspose.Words will remove paragraph's text completely with its paragraph mark. options.SmartParagraphBreakReplacement = true; doc.Range.Replace(new Regex(@"TEXT1&p"), "", options); // But if the option is set to 'false', // Aspose.Words will mimic Word and remove only paragraph's text and leaves the paragraph mark intact. options.SmartParagraphBreakReplacement = false; doc.Range.Replace(new Regex(@"TEXT2&p"), "", options); doc.Save("out.docx"); // This code example produces the following results: // ┌───────────────────────┐ // │ ┌───────────────────┐ │ // │ |¶ | | // | └───────────────────┘ │ // └───────────────────────┘ // ┌───────────────────────┐ // │ ¶ │ // │ ┌───────────────────┐ │ // │ |¶ | | // | └───────────────────┘ │ // └───────────────────────┘
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn