Specify file type when loading a document

When loading a document by specifying a path to a file or using FileStream, GroupDocs.Viewer determines file type by extension. Otherwise, GroupDocs.Viewer tries to determine file type by its signature or content. It takes time and may affect performance.

You can specify the file type using LoadOptions. If you do this, GroupDocs.Viewer skips file type detection and use the specified type.

The following code snippet shows how to specify the file type when loading a document:

// Implement a method that returns a stream with document data.
Stream stream = GetFileStream("sample.docx");

// Specify the file type.
LoadOptions loadOptions = new LoadOptions(FileType.DOCX);

//Render a file.
using (Viewer viewer = new Viewer(stream, loadOptions)
{
    HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources();
    viewer.View(viewOptions);
}