Taking a lot of time to load the documents in Groupdocs.viewerv

Hello,

I am using GroupDocs.Viewer 20.8 in my application, and I have some documents which is taking huge amount of time to load in a GroupDocs Viewer

I also tried the same on the online portal but still it is taking Time to load online also.

sharing the documents for your reference.

Accel IT_6000014825_Gurgaon.pdf (48.4 KB)

ANK05611.pdf (1.3 MB)

SRN 1100018422 PO 6000014825.pdf (222.3 KB)

Yash_6100001998.pdf (45.7 KB)

YTL2409010 - AGILUS PATHLABS PRIVATE LIMITED - Sep’24 to Nov’24.pdf (1.7 MB)

Please note that the issue is raised by our client and it needs to be fixed on priority.

Hi @Niteen_Jadhav

We’re sorry for such inconvenience. Thanks for sharing the sample PDF files. But the GroupDocs.Viewer has different ways to view the input document: as HTML (HtmlViewOptions), PDF (PdfViewOptions), PNG (PngViewOptions) and JPEG (JpgViewOptions). Each of these modes has its own performance profile. Also, for each of these modes there are plenty of settings, which can affect the performance as well. So please provide a sample source code, using which you observe the long processing time, or at least describe the viewing mode and options, so we may narrow the investigation and reproduce your issue.

Thanks and waiting for your reply.

With best regards,
Denis

sharing the api with you

[HttpPost]
[Route("api/GroupDocsViewerApi/LoadDocumentDescription")]
public HttpResponseMessage LoadDocumentDescription(PostedDataEntity postedData)
{
    SerilogInternal seri = new SerilogInternal(1000);
    try
    {
        seri.LogMessage("Executed");
        LoadDocumentEntity loadDocumentEntity = GetDocumentPages(postedData, globalConfiguration.GetViewerConfiguration().GetPreloadPageCount() == 0);

        // return document description
        return this.Request.CreateResponse(HttpStatusCode.OK, loadDocumentEntity);
    }
    catch (PasswordRequiredException ex)
    {
        // set exception message
        return this.Request.CreateResponse(HttpStatusCode.Forbidden, new DocPro.DMS.DocProDMSGroupDocs.Products.Common.Resources.Resource().GenerateException(ex, postedData.password));
    }
    catch (Exception ex)
    {
        // set exception message
        return this.Request.CreateResponse(HttpStatusCode.InternalServerError, new DocPro.DMS.DocProDMSGroupDocs.Products.Common.Resources.Resource().GenerateException(ex, postedData.password));
    }
}

private LoadDocumentEntity GetDocumentPages(PostedDataEntity postedData, bool loadAllPages)
{
    // get/set parameters
    string documentGuid = GetDocumentPath(postedData.guid); //postedData.guid;
    string password = string.IsNullOrEmpty(postedData.password) ? null : postedData.password;

    var fileFolderName = Path.GetFileName(documentGuid).Replace(".", "_");
    string fileCacheSubFolder = Path.Combine(cachePath, fileFolderName);

    if (!File.Exists(documentGuid))
    {
        throw new GroupDocsViewerException("File not found.");
    }

    IViewerCache cache = new FileViewerCache(cachePath, fileCacheSubFolder);

    LoadDocumentEntity loadDocumentEntity;
    var htmlMode = string.IsNullOrEmpty(postedData.IsHTMLMode) ? "false" : postedData.IsHTMLMode;
    if (htmlMode != "false")
    {
        using (HtmlViewer htmlViewer = new HtmlViewer(documentGuid, cache, GetLoadOptions(password)))
        {
            loadDocumentEntity = GetLoadDocumentEntity(loadAllPages, documentGuid, fileCacheSubFolder, htmlViewer);
        }
    }
    else
    {
        using (PngViewer pngViewer = new PngViewer(documentGuid, cache, GetLoadOptions(password)))
        {
            loadDocumentEntity = GetLoadDocumentEntity(loadAllPages, documentGuid, fileCacheSubFolder, pngViewer);
        }
    }

    return loadDocumentEntity;
}

private static dynamic GetviewInfo(string isHtmlMode, ICustomViewer customViewer)
{
	if (isHtmlMode != "false")
	{
		return customViewer.GetViewer().GetViewInfo(ViewInfoOptions.ForHtmlView());//this is taking lot of time
	}
	else
	{
		return customViewer.GetViewer().GetViewInfo(ViewInfoOptions.ForPngView(false));//this is taking lot of time
	}
}

private static LoadDocumentEntity GetLoadDocumentEntity(bool loadAllPages, string documentGuid, string fileCacheSubFolder, ICustomViewer customViewer, string htmlMode="")
{
    if (loadAllPages)
    {
        customViewer.CreateCache();
    }

    dynamic viewInfo = GetviewInfo(htmlMode, customViewer);// customViewer.GetViewer().GetViewInfo(ViewInfoOptions.ForHtmlView());
    LoadDocumentEntity loadDocumentEntity = new LoadDocumentEntity();

    if (!Directory.Exists(cachePath))
    {
        Directory.CreateDirectory(cachePath);
    }

    TryCreatePagesInfoXml(fileCacheSubFolder, viewInfo, out string pagesInfoPath);

    //foreach (Page page in viewInfo.Pages)
    //{
    //    PageDescriptionEntity pageData = GetPageInfo(page, pagesInfoPath);
    //    if (loadAllPages)
    //    {
    //        pageData.SetData(GetPageContent(page.Number, documentGuid, cachePath, "N"));
    //    }

    //    loadDocumentEntity.SetPages(pageData);
    //}
    for (var i = 1; i <= viewInfo.Pages.Count; i++)
    {
        PageDescriptionEntity pageData = new PageDescriptionEntity();
        pageData.Number = i;
        loadDocumentEntity.SetPages(pageData);
    }
    loadDocumentEntity.SetGuid(documentGuid);
    return loadDocumentEntity;
}

GetviewInfo this function is taking huge amount of time and additionally same documents are also taking time when tried online on Groupdocs portal

Hi @Niteen_Jadhav

Thank you for providing the source code, especially with comments, which point us on the problematic places. We checked the performance in according to your code: we measured the Viewer.GetViewInfo() calls with ViewInfoOptions.ForHtmlView() argument with and without the renderSinglePage boolean flag, in both trial and licensed modes, in .NET Framework 4.6.2 and .NET 6.0 environments.

Our performance measurements show that for the latest version 24.10 the GroupDocs.Viewer performs such operations quite fast. It takes from 1 ms for “Yash_6100001998.pdf” to 800 ms for “Accel IT_6000014825_Gurgaon.pdf” for .NET Framework 4.6.2, while for the .NET 6.0 the results are even a little bit faster. Anyway, even taking into accound the difference in hardware configuration, background processes on PC and so on, we found that it never surpass 1 second to complete the Viewer.GetViewInfo() call for any of provided documents.

We think that the reason of bad performance in your case is using a very old version 20.8 — it is really very ancient, and performance was greatly improved during last 4 years. So please update the GroupDocs.Viewer for .NET to the latest 24.10 version and the problem will be solved.

With best regards,
Denis Gvardionov

But I am facing the same issue on online portal as well

Hi @Niteen_Jadhav

Please note that you have provided the source code sample, and I have tested the performance of especially the code you provided: the method private static dynamic GetviewInfo(string isHtmlMode, ICustomViewer customViewer), where the Viewer.GetViewInfo(ViewInfoOptions.ForHtmlView()) calls are made and which you have marked with the this is taking lot of time comment.

Regarding the online portal — it does not use Viewer.GetViewInfo() at all, because the Viewer.GetViewInfo() method returns a ViewInfo class instance, which is a metadata about the input file. Instead the online portal internally invokes the Viewer.View(), which actually performs a viewing the document. So your code and code behind the online portal are simply very different, so that’s why incorrect to compare their performance directly.

With best regards,
Denis Gvardionov

can you please share temporary license so that we will check and based on that we will purchase the updated license

@Niteen_Jadhav

Sure, you can get a temporary license through the purchase wizard by clicking here.

  1. Sign up with your work email. Free mail services are not allowed.

  1. Use Get a temporary license button on the second step.