Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
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.
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 get_ZoomPercent() property, or the view mode using the get_ViewType() property.
The following code example shows how to ensure that a document is displayed at 50% when opened in Microsoft Word:
If you want to set the number of characters per line, use the get_CharactersPerLine() property. You can also set the number of lines per page for a Word document – use the get_LinesPerPage() 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:
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 get_MswVersion() 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:
The OptimizeFor 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:
Q: How can I set the zoom level that Word uses when the document is opened?
A: Use the ViewOptions object of the document and call set_ZoomPercent(50); (or any desired percentage). The setting is stored in the document and Word will apply it on open.
Q: Which properties control the number of lines per page or characters per line?
A: Access the document’s PageSetup via Section::get_PageSetup() (for example, doc->get_FirstSection()->get_PageSetup()) and use set_LinesPerPage(int) and set_CharactersPerLine(int) to define the grid size.
Q: How do I add or change editing languages for a document?
A: Use the LanguagePreferences object of LoadOptions: call loadOptions->get_LanguagePreferences()->AddEditingLanguage(EditingLanguage::Japanese); (or another language), then load the document with these options. You can also set the default editing language with loadOptions->get_LanguagePreferences()->set_DefaultEditingLanguage(EditingLanguage::Russian);.
Q: How can I prevent Word from opening a document in Compatibility mode?
A: Call doc->get_CompatibilityOptions()->OptimizeFor(MsWordVersion::Word2016); and, if needed, set Compliance to Iso29500_2008_Transitional or higher. This tells Word to treat the file as created for the specified version.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.