Set file type when loading a document

When passing file path or FileStream into Viewer class constructor the GroupDocs.Viewer determines file type by file extension but when file passed as a stream the GroupDocs.Viewer tries to detect file type by file signature or file content and this may affect application performance. The API enables you to specify the file type of the processing document by passing LoadOptions object as the second parameter of Viewer class constructor. When you’re passing file type it instructs GroupDocs.Viewer to skip file type detection feature and proceed with rendering.

The following code sample shows how to pass the file type when loading a document.

Stream stream = GetFileStream("sample.docx");
LoadOptions loadOptions = new LoadOptions(FileType.DOCX);

using (Viewer viewer = new Viewer(stream, loadOptions)
    HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources();

© Aspose Pty Ltd 2001-2022. All Rights Reserved.