彩票走势图

.NET版文档管理利器Aspose.Words v20.5发布!用例解析5大新功能!

原创|产品更新|编辑:李显亮|2020-05-07 10:44:20.823|阅读 170 次

概述:Aspose.Words for .Net更新至新版本v20.4,主要新增5大特点,包括:提供显示/隐藏语法和拼写错误的功能;添加辅助方法以将水印插入标头;添加了为OOXML文档设置压缩级别的功能;添加和选项以删除重复样式到Document.Cleanup功能; Aspose.Words为DOCX写入错误的字节,同时修复多项Bug,欢迎下载体验。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

五一小长假刚过,大家又进入了忙碌的工作中,.NET版Aspose.Words也为大家带来了5月的新版本!Aspose.Words for .Net是一种高级Word文档处理API,用于执行各种文档管理和操作任务。API支持生成,修改,转换,呈现和打印文档,而无需在跨平台应用程序中直接使用Microsoft Word。

主要特点如下:

  • 提供显示/隐藏语法和拼写错误的功能。
  • 引入了可在文档内部使用水印的新帮助程序类。
  • 添加了为OOXML文档设置压缩级别的功能。

>>你可以点击这里下载Aspose.Words for .NET v20.5测试体验

具体更新内容

key 概述 类别
WORDSNET-10403 向“仅隐藏本文档中的拼写错误”添加功能 新功能
WORDSNET-4879 添加辅助方法以将水印插入标头 新功能
WORDSNET-10404 将功能添加到“仅隐藏本文档中的语法错误” 新功能
WORDSNET-20094 添加和选项以删除重复样式到Document.Cleanup功能 新功能
WORDSNET-20169 Aspose.Words为DOCX写入错误的字节 新功能
完整更新细则请参考:【Aspose.Words for .NET v20.5更新说明】

公共API更改

①添加了新的公共属性OoxmlSaveOptions.CompressionLevel,指定压缩级别“SuperFast”以保存文档

///
/// Specifies the compression level used to save document.
///
publicCompressionLevel CompressionLevel

用例:说明如何指定压缩级别“ SuperFast”(由Microsoft Word使用)以保存文档。

Document doc = new Document("in.docx");
OoxmlSaveOptions so = new OoxmlSaveOptions(SaveFormat.Docx);
so.CompressionLevel = CompressionLevel.SuperFast;
doc.Save("out.docx", so);

②添加了新的公共方法FontInfo.GetEmbeddedFontAsOpenType(),将Embedded OpenType格式的嵌入字体转换为OpenType

///
/// Gets an embedded font file in OpenType format. Fonts in Embedded OpenType format are converted to OpenType.
///
/// Specifies the font style to retrieve.
/// Returns null if the specified font is not embedded.
publicbyte[] GetEmbeddedFontAsOpenType(EmbeddedFontStyle style)

③引入了可在文档内部使用水印的新帮助程序类

新属性“水印”已添加到Document类。

///
/// Provides access to the document watermark.
///
publicWatermark Watermark {get; }

新的Watermark类允许从文档中添加/删除水印。可以从文本或图像创建水印。

///
/// Represents class to work with document watermark.
///
publicsealedclassWatermark
{
///
/// Adds Text watermark into the document.
///
/// Text that displays as a watermark.
///
/// The text length should be in the range from 1 to 200 inclusive.
/// The text cannot be null or consist only of whitespaces.
///
///
/// Throws when the text length is out of range or the text consists only of whitespaces.
///
///
/// Throws when the text is null.
///
publicvoidSetText(stringtext)
///
/// Adds Text watermark into the document.
///
/// Text that displays as a watermark.
/// Defines additional options for the text watermark.
///
/// The text length should be in the range from 1 to 200 inclusive.
/// The text cannot be null or consist only of whitespaces.
///
///
/// Throws when the text length is out of range or the text consists only of whitespaces.
///
///
/// Throws when the text is null.
///
/// If options is null, the watermark will be set with default properties.
publicvoidSetText(stringtext, TextWatermarkOptions options)
///
/// Adds Image watermark into the document.
///
/// Image that displays as a watermark.
///
/// Throws when the image is null.
///
publicvoidSetImage(Image image)
///
/// Adds Image watermark into the document.
///
/// Image that displays as a watermark.
/// Defines additional options for the image watermark.
///
/// Throws when the image is null.
///
/// If options is null, the watermark will be set with default properties.
publicvoidSetImage(Image image, ImageWatermarkOptions options)
///
/// Removes watermark.
///
publicvoidRemove()
///
/// Returns watermark type.
///
publicWatermarkType Type {get; }
}

提供了新的枚举,以确定文档内的水印类型。

///
/// Specifies the watermark type.
///
publicenumWatermarkType
{
///
/// Indicates that the text will be used as a watermark.
///

Such a watermark corresponds to a WordArt object.

///
Text,
///
/// Indicates that the image will be used as a watermark.
///

Such a watermark corresponds to a shape with image.

///
Image,
///
/// Indicates watermark is no set.
///
None
}

提供了新的枚举,可将文本水印设置为对角或水平布局。

///
/// Defines layout of the watermark relative to the watermark center.
///
publicenumWatermarkLayout
{
///
/// Horizontal watermark layout. Corresponds to 0 degrees of rotation.
///
Horizontal = 0,
///
 /// Diagonal watermark layout. Corresponds to 315 degrees of rotation.
///
Diagonal = 315
}

对于图像水印:

///
/// Contains options that can be specified when adding a watermark with image.
///
publicclassImageWatermarkOptions
{
///
/// Gets or sets the scale factor expressed as a fraction of the image. The default value is 0 - auto.
///
///
///

Valid values range from 0 to 65.5 inclusive.

///

Auto scale means that the watermark will be scaled to its max width and max height relative to

/// the page margins.


///
///
/// Throws when argument was out of the range of valid values.
///
publicdoubleScale {get;set; }
///
/// Gets or sets a boolean value which is responsible for washout effect of the watermark.
/// The default value is true.
///
publicboolIsWashout {get;set; }
}

用例1:添加带有特定选项的文本水印

Document doc = new Document(pathFile);
  
TextWatermarkOptions options = new TextWatermarkOptions()
{
    FontFamily = "Arial",
    FontSize = 36,
    Color = Color.Black,
    Layout = WatermarkLayout.Horizontal,
    IsSemitrasparent = false
};
  
doc.Watermark.SetText("Test", options);

用例2:使用特定选项添加图像水印

Document doc = new Document(pathFile);
  
ImageWatermarkOptions options = new ImageWatermarkOptions()
{
    Scale = 5,
    IsWashout = false
};
  
doc.Watermark.SetImage(Image.FromFile(filePath), options);

用例3:从文档中删除水印

Document doc = new Document(pathFile);
if (doc.Watermark.Type == WatermarkType.Text)
    doc.Watermark.Remove();

④添加了新的公共属性Document.ShowGrammaticalErrors,显示语法错误

///
/// Specifies whether to display grammar errors in this document.
///
publicboolShowGrammaticalErrors

用例:说明如何显示语法错误

Document doc = new Document("in.doc");
doc.ShowGrammaticalErrors = true;
doc.Save("out.doc");

⑤添加了新的公共属性Document.ShowSpellingErrors,显示拼写错误

用例:说明如何显示拼写错误

Document doc = new Document("in.doc");
doc.ShowSpellingErrors = true;
doc.Save("out.doc");

Aspose是目前国内外非常火爆且功能强大的文件格式敏捷开发控件,但因为产品众多、技术问题复杂等因素,也常常遭受开发人员吐槽。如果您也正在使用Aspose相关产品,点击下方按钮,来谈谈Aspose的优劣,您的感受对我们相当宝贵哦~


标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn


为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP