Free Support Forum - groupdocs.com

How to load document from stream and view it in .NET

Hi,

I would like to ask how can I load file from stream/byte area.

Thanks

John

@jvocuenca

Please let us know the GroupDocs API name, version and variant (e.g. Java or .NET) that you’re evaluating or using. We’ll then assist you accordingly.

.NET. I am using trying to create an MVC application using this template (https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET-MVC-App). I want to know how can I load file from stream because it will be coming from a sharepoint list. Hoping for your immediate assistance. Thank you very much. :slight_smile:

1 Like

I am using GroupDocs.Viewer 20.6, MVC5, SharePoint 2013. Thanks

@jvocuenca

This is how you load document from a stream. GroupDocs.Viewer for .NET allows you to load documents from different sources. Please have a look at this documentation article.

Thanks for your reply. I added the code below but still the document is not displayed.

string outputDirectory = @“C:\inetpub\wwwroot\wss\VirtualDirectories\5”;
string cachePath = Path.Combine(outputDirectory, “CACHE”);
string pageFilePathFormat = Path.Combine(cachePath, “page_{0}.html”);

        FileCache cache = new FileCache(cachePath);
        ViewerSettings settings = new ViewerSettings(cache);

        using (var vwr = new Viewer(Server.MapPath("\\App_Data\\calibre.docx"), settings))
        {
            HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat);
            vwr.View(viewOptions);
        }

I am also trying to implement this https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET-SharePoint-WebPart. How can I also load the file from SharePoint List? I am using GroupDocs.Viewer 17.3. Thanks.

@jvocuenca

When you run the above mentioned code, do you get HTML output or rendering of the source (DOCX) file in VirtualDirectories\5? There must be the HTML output in the specified directory.

Yes. There are html files but it is not shown in the viewer.

1 Like

Do you have responsive UI version for version 2.19. I have no issues using this version but the interface is not responsive to screen size.

@jvocuenca

Let us brief you about the API processing. GroupDocs.Viewer for .NET basically renders or converts a source file to Image, Html or Pdf formats (it depends on your business needs).
For example in your case you care rendering a DOCX file to HTML. Once the output is generated in the specified path, you have to display it in browser or any other application (e.g. Window forms). API itself doesn’t pick the rendered output files and display them in browser. It just renders the source file to any of the supported output formats. You may find this documentation article helpful.

Please download and explore this open-source example project. Have a look at this video demo as well.