Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
When loading a document, you can set some advanced properties. Aspose.Words provides you with theLoadOptionsclass, which allows more precise control of the load process. Some load formats have a corresponding class that holds load options for this load format, for example, there isPdfLoadOptionsfor loading to PDF format orTxtLoadOptionsfor loading to TXT.This article provides examples of working with options of theLoadOptionsclass.
Different versions of the Microsoft Word application can display documents indifferently. For example, there is a well-known problem with OOXML documents such as DOCX or DOTX produced using WPS Office. In such case essential document markupelements may be missing or may be interpreted differently causing Microsoft Word 2019 to show such a document differently compared to Microsoft Word 2010.
By default Aspose.Words opens documents using Microsoft Word 2019 rules. If you need to to make document loading appear as it would happen in one of the previousMicrosoft Word application versions, you should explicitly specify the desired version using theMswVersionproperty of theLoadOptionsclass.
The following code example shows how to set theMicrosoft Word version with load options:
The details of displaying a document in Microsoft Word depend not only on the application version and theMswVersionproperty value but also on the language settings. Microsoft Word may show documents differently depending on the “Office Language Preferences” dialog settings, that can be found in “File → Options → Languаge”. Using this dialog a user can select, for example, primary language, proofing languages, display languages, and so on. Aspose.Words provides theLanguagePreferencesproperty as the equivalent of this dialog. If Aspose.Words output differs from the Microsoft Word output, set the appropriate value forEditingLanguage– this can improve the output document.
The following code example showshow to set Japanese asEditingLanguage:
Some documents may be corrupted, contain invalid entries, or have features not currently supported by Aspose.Words. If you want to know about problems that occurred while loading a document, Aspose.Words provides theIWarningCallbackinterface.
The following code example shows the implementation of theIWarningCallbackinterface:
Toget information about all problems throughout the load time, use the WarningCallback property.
The following code example showshow to use this property:
A document may contain external links to images located somewhere on a local disk, network, or Internet. Aspose.Words automatically loads such images into a document, but there are situations when this process needs to be controlled. For example, to decide whether we really need to load a certain image or perhaps skip it. TheResourceLoadingCallbackload option allows you to control this.
The following code example shows the implementation of theIResourceLoadingCallbackinterface:
The following code example showshow to use theResourceLoadingCallbackproperty:
Aspose.Words supports extremely large documents that have thousands of pages full of rich content. Loading such documents may require much RAM. In the process of loading, Aspose.Words needs even more memory to hold temporary structures used to parse a document.
If you have a problem with the Out of Memory exception while loading a document, try to use theTempFolderproperty. In this case, Aspose.Words will store some data in temporary files instead of memory, and this can help avoid such an exception.
The following code example showshow to setTempFolder:
Most modern document formats store their content in Unicode and do not require special handling. On the other hand, there are still many documents that use some pre-Unicode encoding and sometimes either miss encoding information or do not even support encoding information by nature. Aspose.Words tries to automatically detect the appropriate encoding by default, but in a rare case you may need to use an encoding different from the one detected by our encoding recognition algorithm. In this case, use theEncodingproperty to get or set the encoding.
The following code example showshow to set the encoding to override the automatically chosen encoding:
You can load Word documents encrypted with a password. To do this, use a special constructor overload, which accepts aLoadOptionsobject. This object contains thePasswordproperty, which specifies the password string.
The following code example shows how to load a document encrypted with a password:
If you do not know in advance whether the file is encrypted, you can use theFileFormatUtilclass, which provides utility methods for working with file formats, such asdetectingthe file format or converting file extensions to/from file format enumerations.To detect if the document is encrypted and requires a password to open it, use the IsEncrypted property.
The following code example shows how to verify OpenDocument either it is encrypted or not:
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.