如何使用Aspose.Words for .NET设置语言首选项和删除我的信息?

Aspose.Words For .Net是一种高级Word文档处理API,用于执行各类文档管理和操做任务。API支持生成,修改,转换,呈现和打印文档,而无需在跨平台应用程序中直接使用Microsoft Word。此外,API支持全部流行的Word处理文件格式,并容许将Word文档导出或转换为固定布局文件格式和最经常使用的图像/多媒体格式。布局

【下载Aspose.Words for .NET最新试用版】code

设置语言首选项

在MS Word中显示文档取决于在该文档的默认值中设置的语言。可是,若是没有语言设置为默认值,该怎么办?在这种状况下,Word从“ 设置Office语言首选项 ”对话框中获取信息,例如,能够在Word 2016中的“文件 - >选项 - >语言”菜单下找到。使用Aspose.Words,您能够设置语言首选项使用LanguagePreferences类。orm

下面的代码示例显示了如何将日语添加到编辑语言中:资源

//文档目录的路径。
LoadOptions loadOptions = new LoadOptions();
loadOptions.LanguagePreferences.AddEditingLanguage(EditingLanguage.Japanese);
Document doc = new Document(dataDir + @ "languagepreferences.docx" , loadOptions);
int localeIdFarEast = doc.Styles.DefaultFont.LocaleIdFarEast;
if (localeIdFarEast == ( int )EditingLanguage.Japanese)
Console.WriteLine( "The document either has no any FarEast language set in defaults or it was set to Japanese originally." );
else
Console.WriteLine( "The document default FarEast language was set to another than Japanese language originally, so it is not overridden." );

下面的代码示例显示如何将俄语设置为默认编辑语言:文档

//文档目录的路径。
LoadOptions loadOptions = new LoadOptions();
loadOptions.LanguagePreferences.SetAsDefault(EditingLanguage.Russian);
Document doc = new Document(dataDir + @ "languagepreferences.docx" , loadOptions);
int localeId = doc.Styles.DefaultFont.LocaleId;
if (localeId == ( int )EditingLanguage.Russian)
Console.WriteLine( "The document either has no any language set in defaults or it was set to Russian originally." );
else
Console.WriteLine( "The document default language was set to another than Russian language originally, so it is not overridden." );

从文档中删除我的信息

若是要与其余人共享Word文档,能够删除我的信息,例如做者姓名和公司。您能够使用Document.RemovePersonalInformation属性设置标志,指示Microsoft Word将在保存文档时从注释,修订和文档属性中删除全部用户信息。get

注意:在Aspose.Words中处理文档时,设置此选项实际上不会删除我的信息,而且仅影响Microsoft Word行为。it

Document doc = new Document(dataDir + "Properties.doc" );
doc.RemovePersonalInformation = true ;
dataDir = dataDir + "RemovePersonalInformation_out.docx" ;
doc.Save(dataDir);

>>为你推荐:Aspose专题 - Aspose最新资源合集io

ASPOSE技术交流QQ群(642018183)已开通,各种资源及时分享,欢迎交流讨论!(扫描下方二维码加入群聊)table

相关文章
相关标签/搜索