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.
- Sign up with your work email. Free mail services are not allowed.
- Use Get a temporary license button on the second step.
Sorry, I was busy with other Activities.
I tried the license provided but after using the license I found that I am only able to work with first 2 pages of the document (View/merge/search/TextRedection)
can you share a temporary license without these limitations for 15 days to 1 month so that I can check these functionality locally and based on that I need to buy the license if required.
sharing the license file (Actual/Temp) which I rec’d
Original GroupDocs.Total.zip (720 Bytes)
Temp GroupDocs.Totalfor.NET.zip (951 Bytes)
Hi @Niteen_Jadhav
When you see only first two pages of the document, while actually it has more pages, and you see the red trial label on the top of the each page — this means that the GroupDocs.Viewer works in the trial mode, because no license was applied at all or the applied license is invalid or expired.
I’ve checked both license files you have provided with the latest GroupDocs.Viewer for .NET version 24.10.
- Regarding the “GroupDocs.Total.lic” from “Original GroupDocs.Total.zip” archive - it was expired in 2020 so it is normal that trial limitations are applied.
- Regarding the “GroupDocs.Totalfor.NET.lic” from “Temp GroupDocs.Totalfor.NET.zip” - it will expire on December 8 and now is working ok, I checked it on my side and there are no trial limitations with it.
Please check the way how you’re referencing the license file. You should have something like that in your project:
string licensePath = @"D:\full\path\GroupDocs.Totalfor.NET.lic";
License lic = new License();
lic.SetLicense(licensePath);
Please note that if the path here is incorrect, no exception will be thrown, but the GroupDocs.Viewer will work in trial mode.
Also please note that this code should be invoked before you’ve instantiated a Viewer
class instance.
Please check all of these and tell us the result.
With best regards,
Denis Gvardionov
Thank you for your reply,
please find below screenshots for your reference.
LicenseDocumentshows2PagesandWaterMark.PNG.jpg (41.0 KB)
licenseError.png (76.5 KB)
LicensePathInApp.png (76.2 KB)
licensePath.PNG (16.3 KB)
license.png (16.6 KB)
I am still getting the same error, requesting you to look into this and also provide the extension as we are not able to test anything till now.
@Niteen_Jadhav
Since the license GroupDocs.Totalfor.NET.lic
is valid you should be able to use it with the latest version of GroupDocs products.
The only issue that I can think of at the moment that if you are using some old version of the product and it does not support reading the new license.
Can you please provide the versions of the products you’re using and if possible sample console application to reproduce the issue.