Free Support Forum -

Displaying documents from blobs

Good afternoon,

I have downloaded the latest GroupDocs.Viewer-for-.NET-MVC example and I am looking to see if I can achieve the following:

  • Retrieve and display a blob from a SQL database.

I know how to get the blob and return it as a stream, I just don’t know where this should be placed within the GroupDocs MVC example.

Any pointers would be greatly appreciated.


Thanks for posting your inquiry.

GroupDocs.Viewer allows you to render the documents directly from the file streams (see working with streams). In order to render document from file stream particularly in GroupDocs.Viewer for .NET MVC application, you just need to replace the documentGuid with the file stream object in all occurrences of the following methods in ViewerApiController.cs (see screenshot for reference).

  • GetPages
  • GetDocumentInfo

Currently, the API doesn’t provide an overload of RotatePage method (that is used in the RotateDocumentPages method of ViewerApiController.cs class) to work with the file stream. We have already logged it in our Issue Tracking System (as VIEWERNET-1864) to check if it is feasible to implement RotatePage method for file streams. In case the page rotation is not a necessary feature for you, you can skip it unless we get the updates regarding the overload of RotatePage method.
On the other hand, if rotate page feature is essential for you then you may consider the following solution instead of rendering directly from the stream. Please note that this solution will be suitable if you know the file extension of the blob as well.

  1. Implement custom file storage that reads the file from the database and maintains the cache locally
  2. Use the file name as documentGuid in the application without any changes in GetPages and GetDocumentInfo methods

For reference, you can download this sample console application that demonstrates how to maintain the custom storage by reading the files from the database. However, if the file extension is unknown in your case, then you can share that with us. Hope it helps.