如何使用Aspose.Words for .NET設置語言首選項和刪除我的信息?

Aspose.Words For .Net是一種高級Word文檔處理API,用於執行各類文檔管理和操做任務。API支持生成,修改,轉換,呈現和打印文檔,而無需在跨平臺應用程序中直接使用Microsoft Word。此外,API支持全部流行的Word處理文件格式,並容許將Word文檔導出或轉換爲固定佈局文件格式和最經常使用的圖像/多媒體格式。佈局

【下載Aspose.Words for .NET最新試用版】spa

設置語言首選項


在MS Word中顯示文檔取決於在該文檔的默認值中設置的語言。可是,若是沒有語言設置爲默認值,該怎麼辦?在這種狀況下,Word從「 設置Office語言首選項 」對話框中獲取信息,例如,能夠在Word 2016中的「文件 - >選項 - >語言」菜單下找到。使用Aspose.Words,您能夠設置語言首選項使用LanguagePreferences類。code

下面的代碼示例顯示瞭如何將日語添加到編輯語言中: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." );

下面的代碼示例顯示如何將俄語設置爲默認編輯語言:ci

//文檔目錄的路徑。
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將在保存文檔時從註釋,修訂和文檔屬性中刪除全部用戶信息。資源

注意:在Aspose.Words中處理文檔時,設置此選項實際上不會刪除我的信息,而且僅影響Microsoft Word行爲。文檔

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

 

爲你推薦:Aspose專題 - Aspose最新資源合集get


ASPOSE技術交流QQ羣(642018183)已開通,各種資源及時分享,歡迎交流討論!(掃描下方二維碼加入羣聊)it

相關文章
相關標籤/搜索