Viewer for loading preview first page

I am implementing document previews using GroupDocs in a document management application and have the following questions:

  1. Each time I open a document record, I want to preview one page. Which method do you recommend, considering that I may have millions of documents in the filestorage and thousands of accesses to the document record?
  2. Are there any limitations when using the browser to view a document with, for example, 100 pages? I am concerned about clients using computers with fewer resources. Is any cache created on the server?
  3. What are the possibilities for previewing multiple attachments simultaneously in the preview?

Thank you in advance for your help.

@ambdev

I’m sorry for the delayed response. Let me better understand you case. Do you use GroupDocs.Viewer.UI package or you implementing your own UI?

We are using GroupDocs.Viewer-for-.NET WebForms package.

@ambdev

  1. Yes, you can set PreloadPageCount to 1 in Global.asax.cs file:
var uiConfig = UIConfig.Instance
    .SetViewerType(viewerType)
    .SetPreloadPageCount(1);
  1. We do not have any limitations on number of pages when valid license is set. For limitations on computers with fewer resources it has to be tested as document with 100 pages and text only or document with 100 pages with graphics will produce different output.
    Yes, caching to the local folder is enabled by default here. Cached files are stored to the folder that you can specify here, by default it is ~/Storage/Cache folder.

  2. Only one file at the time can be previewed. Can you please clarify if you want to preview attachments of email messages like MSG or EML?

  1. I would like the viewer to function normally, displaying all pages when accessing a file. However, I also want to include a thumbnail of the first page of the file on our page.

  2. We are managing millions of files within our filesystem. Creating a local cache appears to duplicate each file, as a separate folder with an HTML file for each loaded page is generated. This could lead to a significant increase in our filesystem’s size. We need to explore alternative solutions to avoid this potential storage issue.

  3. I have a metadata record that includes the main file as a thumbnail, and allows the attachment of various types of documents. Our idea is to have an option to view the different attachments associated with this record using a viewer. Is this possible?

@ambdev

  1. Sure, you can generate the thumbnail for the first page using the following code
using System;
using System.IO;
using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;

var fileName = "mydocument.docx";
MemoryStream pageStream = new MemoryStream();
CreateThumbnail(fileName, pageStream);

private static void CreateThumbnail(string fileName, Stream pageStream)
{
    using (Viewer viewer = new Viewer(fileName))
    {
        // or JpgViewOptions
        PngViewOptions viewOptions = new PngViewOptions(
            pageNumber => pageStream,
            (pageNumber, pageStream) => { });

        // set width or height
        viewOptions.Width = 200;
        // or viewOptions.Height = 200;
        viewer.View(viewOptions, 1);
    }
}
  1. You can store cache in any cloud storage. To use any cloud storage you have to implement IFileCache interface. Then you can register it in Global.asax.cs file instead of LocalFileCache.

  2. Yes, you can view any file. While the default LocalFileStorage works with local disc you can use any storage provider. You can pass file path or any identifier through file= query string parameter and load the file from any location.