Groudocs viewer dot net core

We are using group docs viewer in both angular and dot net core we have some queries

  1. In Angular we used gd-viewer component. how we can customize viewer requests from the component?. default api call is ends with “/viewer”
  2. While we are testing with large documents(>100mb) loadDocumentDescription api is taking more than 10 minutes - how to load first 2 or 3 pages faster?
    3.End to end for all api’s customization in dot net core

@Prajneshu

  1. You can find the source code of gd-viewer component at https://github.com/groupdocs-total/GroupDocs.Total-Angular/tree/master/libs/viewer. To customize requests you can implement your own ConfigService, the example you can find here.
export function configServiceFactory() {
  let config = new ConfigService();
  config.apiEndpoint = window.apiEndpoint;
  config.getViewerApiEndpoint = () => window.apiEndpoint;
  config.getConfigEndpoint = () => window.uiSettingsPath;
  return config;
}

// ...

@NgModule({
  // ...
  providers: [
    { provide: APP_BASE_HREF, useValue: '/' },
    { provide: ConfigService, useFactory: configServiceFactory },
  1. It depends on what demo project you’re using but in general you may set PreloadPageCount to a value greater than zero. Can you share what demo you’re running?

  2. GroupDocs.Viewer supports .NET Core 3.1 if I got your question right.

Hi @vladimir.litvinchik thanks for the quick reply. I will try the above code.

@vladimir.litvinchik regarding the 2nd point we are using dot net core version of viewer i am attaching my sample code. we are trying to load some large pdf into the viewer. the time taking for loadDocumentDescription api is around 30 to 40 seconds.

Here is the code in the google drive

@Prajneshu

There are a couple of options here that can improve processing and loading speed.

  • Update packages to the latest versions
  <ItemGroup>
    <PackageReference Include="GroupDocs.Viewer.UI" Version="6.0.11" />
    <PackageReference Include="GroupDocs.Viewer.UI.Api.Local.Cache" Version="6.0.0" />
    <PackageReference Include="GroupDocs.Viewer.UI.Api.Local.Storage" Version="6.0.0" />
    <PackageReference Include="GroupDocs.Viewer.UI.SelfHost.Api" Version="6.0.13" />
  </ItemGroup>
  • Run the app in Release mode
  • Since Viewer creates a lot of files in a Cache folder Microsoft Defender may slow down the app. You can exclude Cache folder from being scanned.
  • Set preload to one page
builder.Services
    .AddGroupDocsViewerUI(config =>
    {
        config.SetPreloadPageCount(1);
    });
  • Warn up the app with some small file

LoadDocumentDescription loads a file into memory and creates object model so it takes time to process all the pages. Unfortunately, we can’t load only one page into memory.

I have encountered a performance issue related to the LoadDocumentDescription method in GroupDocs Viewer. I would appreciate your insights and assistance in resolving this matter. Here are the details:

Initial Loading Delay:

  1. When loading a large PDF into the viewer using LoadDocumentDescription, it takes approximately 2 minutes to complete.
  2. the first 3 pages are displayed in the viewer, as we have preload with 3 pages
  3. The backend cache folder contains an info.json file and HTMLs for the first 3 pages.

Subsequent Document Reload:

  1. Even after deleting the cache folder (including info.json and pages), reloading the same document takes less than 5 seconds.
  2. The document is displayed correctly in the viewer.
  3. I kindly request your guidance on understanding the cause behind the initial delay and the subsequent improvement upon reloading the document. Are there any caching mechanisms or optimizations that may be contributing to this behavior’s?

@Prajneshu

It happens due to the internal caching that we’re using to cache Viewer instance for some period of time, by default it’s 5 minutes. We use this caching to improve the performance of the subsequent calls to the API. It can be disabled or adjusted. See this pull request for more details.

The source code related to this feature can be found in BaseViewer.cs#L126.

Thank you for your detailed response and providing the code reference. We appreciate your assistance thus far.

We have implemented a similar approach in our codebase, including setting the preload page count. However, we are encountering extended loading times of more than 2-5 minutes for certain large documents, even those below 100MB.
Considering this, we are concerned about the potential loading times for documents exceeding 100MB. Our primary objective at the moment is to ensure that the document can be loaded in the viewer within 15 seconds, especially for large documents.

We are open to exploring any possible solutions to address this issue and optimize the loading time for the end user. If necessary, we are willing to perform pre-processing upfront to prepare the document and make it readily available for the user. Our goal is to allow the user to click on the document and have it load swiftly in the viewer.

Waiting for 5 minutes every time for even less than 100MB document is not a viable option, as users may prefer to download and view the document in the meantime.

Thank you once again for your support and expertise. We look forward to your valuable insights and guidance.

@Prajneshu

While in our plans we have performance analysis and performance optimization in GroupDocs.Viewer and GroupDocs.Viewer.UI but these changes won’t solve the main issue. The only way I see right now is pre-processing. This feature is not supported out-of-the-box in GroupDocs.Viewer.UI but since GroupDocs.Viewer.UI code is available you can build your own service that creates cache, so the users won’t wait for cache to be created.

As you said can you guide us what are the services/methods are to implement custom caching?

@Prajneshu

I’ve added the example how you can create cache. It is quite simple but it should give you the idea. All the code including composition level is located in Program.cs file.