Work with Options and Appearance of Word Documents
Sometimes you may need to change the appearance of a document, for example, set language preferences or the number of lines per page.Aspose.Words provides the ability to control how the document will be displayed, as well as some additional options. This article describes such possibilities.
Set Document Display Options
You can control how a document will be displayed in Microsoft Word using the ViewOptions class. For example, you can set a document zoom value using the zoom_percent property, or the view mode using the view_type property.
The following code example shows how to ensure that a document is displayed at 50% when opened in Microsoft Word:
Set Page Display Options
If you want to set the number of characters per line, use the characters_per_line property. You can also set the number of lines per page for a Word document – use the lines_per_page property to get or set the number of lines per page in the document grid.
The following code example shows how to set the number of characters per line and the number of lines per page for a Microsoft Word document:
Set Language Preferences
Displaying a document in Microsoft Word depends on which languages are set as defaults for this document. If no languages are set in defaults, Microsoft Word takes information from the “Set Office Language Preferences” dialog box, which, for example, can be found under “File → Options → Language” in Microsoft Word 2019.
With Aspose.Words, you can also set up language preferences using the LanguagePreferences class. Also note that for the correct display of your document it is necessary to set the Microsoft Word version that the document loading process should match – this can be done using the msw_version property.
The following code example shows how to add Japanese to editing languages:
The following code example shows how to set Russian as the default editing language:
Optimize a Document for a Particular Word Version
The optimize_for method allows optimizing document content, as well as default Aspose.Words behaviour for a particular version of Microsoft Word. You can use this method to prevent Microsoft Word from displaying the “Compatibility mode” ribbon upon document loading. Note that you may also need to set the compliance property to ISO29500_2008_TRANSITIONAL or higher.
The following code example shows how to optimize document content for Microsoft Word 2016: