groupdocs-viewer / GroupDocs.Viewer-for-.NET-UI

UI - User Interface for GroupDocs.Viewer for .NET document viewer and automation API.
MIT License
5 stars 2 forks source link

The methods ReadFileAsync and ResolveFileTypeAsync are called several times for one file that should be displayed #18

Closed vladimir-litvinchik closed 2 years ago

vladimir-litvinchik commented 2 years ago

@vladimir-litvinchik Thank you very much for providing this quick solution! The documents will be shown now.

But one more question comes up: The methods ReadFileAsync and ResolveFileTypeAsync are called several times for one file that should be displayed. For example: 3 times for a singe page visx 5 times for a 8 pages docx 9 times for a 27 pages docx

This is rather inefficient. Especially since for ReadFileAsync the entire file has to be loaded from the database each time. Have I overlooked something or am I doing something wrong?

Originally posted by @ManuelHaas in https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET-UI/issues/17#issuecomment-1139491314

ManuelHaas commented 2 years ago

@vladimir-litvinchik Hi Vladimir, what is the status of multiple loading the files in viewer?

vladimir-litvinchik commented 2 years ago

@ManuelHaas

This and two more open issues are planned for the next week.

vladimir-litvinchik commented 2 years ago

@ManuelHaas

This issue has been partially fixed. The file type is cached at the client now so the method ResolveFileTypeAsync is called only once. Please update the following packages

<PackageReference Include="GroupDocs.Viewer.UI" Version="3.1.8" />
<PackageReference Include="GroupDocs.Viewer.UI.SelfHost.Api" Version="3.1.17" />

The second issue with ReadFileAsync is under investigation.

vladimir-litvinchik commented 2 years ago

@ManuelHaas

I'm sorry for the delayed response. This issue has been fixed and it will require updating the packages to the latest version. Please note that you can adjust the number of pages to be rendered in a single call by setting a number of pages to preload.

services
    .AddGroupDocsViewerUI(config => {
        config.SetPreloadPageCount(3); 
    });

If you specify 0 all the pages will be loaded in at once, so the method ReadFileAsync will be called only one time.

ManuelHaas commented 2 years ago

@vladimir-litvinchik It works now as expected. Thank you!

vladimir-litvinchik commented 2 years ago

@ManuelHaas

Thank you for the feedback!