Specify file type when loading a document
Leave feedback
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:
usingSystem.IO;usingGroupDocs.Viewer;usingGroupDocs.Viewer.Options;// ...Streamstream=GetFileStream("sample.docx");//TODO: implement your method// Specify the file type.LoadOptionsloadOptions=newLoadOptions(FileType.DOCX);//Render a file.using(Viewerviewer=newViewer(stream,loadOptions)){HtmlViewOptionsviewOptions=HtmlViewOptions.ForEmbeddedResources();viewer.View(viewOptions);}
ImportsSystem.IOImportsGroupDocs.ViewerImportsGroupDocs.Viewer.Options' ...
ModuleProgramSubMain(argsAsString())DimstreamAsStream=GetFileStream("sample.docx")'TODO: implement your method
' Specify the file type.
DimloadOptionsAsLoadOptions=NewLoadOptions(FileType.DOCX)'Render a file.
UsingviewerAsViewer=NewViewer(stream,loadOptions)DimviewOptionsAsHtmlViewOptions=HtmlViewOptions.ForEmbeddedResources()viewer.View(viewOptions)EndUsingEndSubEndModule
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.