Load More Pages

Hello, I was wondering if it was possible to load a whole document into memory so there is no loading as a user scrolls. We have noticed that when scrolling fast, you can see a blank page for a little bit before the page loads and were wondering if there was something we could do to fix that. Thanks.


8 Replies

DD Divya Dhayalan Syncfusion Team June 28, 2021 09:34 PM UTC

 
Thank you for contacting Syncfusion support. 
 
On analyzed further, there is memory constrain in framework level itself for WPF applications, which may result poor performance or exceptions while rendering full document into a memory stream if the document has more pages. In 32-Bit process, there is memory barrier in the framework level itself which allocates only a minimal amount of memory and might results in poor performance or out of memory exception.  
 
A 64-bit platform targeted application performs better than 32-bit application. However, it is not possible to force the memory to release before unloading the PdfViewerControl. we have already faced issue in forcing the memory to release when the work is done in WPF platform. We have already reported the issue about memory usage in 64-Bit to Microsoft, https://github.com/dotnet/wpf/issues/1082. According to their update, we found that once a memory is allocated for a resource, the memory will be reserved to reuse in anticipation of future needing that memory. It is normal behavior of the CLR and also that is not leak. So, rendering full document as a memory stream might me difficult with 64-bit application too and which may result poor performance and application hanging issues.  
 
Due to the above memory constrain, we don’t have any plans to render the entire document as a memory stream. If you are facing more delay while rendering PDF pages, please provide the document which will be helpful for us to analyze better on this and provide you a better solution. 
 
Regards, 
Divya 



LO Lucas Oliverrothenberger June 29, 2021 12:13 PM UTC

We are transferring from another WPF PDF library to syncfusion and the one we are transferring from does not have this issue. Also, can't a 32-bit application access 4GB of RAM? Our PDF viewer while idle takes ~45MB of RAM which is far from 4GB. Why can I not load an entire PDF into memory? We are dealing with multiple PDFs at a time that can range from 3 to 100 MB which is still no issue.

Also, the Github issue you linked is closed and is not even an issue with WPF



DD Divya Dhayalan Syncfusion Team June 30, 2021 05:55 PM UTC

Hi Lucas, 

Sorry for the inconvenience. We suspect that there is miscommunication happened when initially we tried to understand your requirement. Initially we suspect that you were reported memory issue with PDF Viewer. Now we could see that your requirement is to load whole document to memory or load more pages to avoid blank display of pages in between the control when on fast scrolling. Please find the details below. 

Virtualization: We do load the whole document into the memory and parse the basic information such as page count, dimensions etc..., to specify the control height and updating the toolbar values. But only the page parsing process from the PDF document is done in on-demand basis. Currently we parse and keep only few pages in live based on the current scrolled location and the View Port size in a virtualized way.  

Page parsing process: The pages parsing process involves creating a bitmap image of the page from PDFium along with extracting and storing the information present in the pages such as text, images, annotations, calculating the bounds of the text for select and search etc..., So, parsing and keeping all the bitmap images and resource collection will be both time and memory consuming.  

Magnification: Also, in every zoom change, we generate new image with respect to the current magnification to maintain the content quality. In those cases, we may need to keep images with different magnifications in live.  It will be even more in the case of documents with more pages or documents with heavy content pages. 

Resource sharing and scroll performance: For some of the resource sharing across many pages, we need to handle in the UI thread, instead of background thread as it might result in dead lock. So, when parsing more pages, this might result in affecting the smooth scrolling performance when increasing the buffer pages. So, we wait until the scroll is stopped, and parse the pages to generate the images. So that the blank pages are seen in between when on fast scrolling. The reason for parse and keep only the few pages in live is not only for keeping the memory under limit, but also for maintaining the smooth scrolling experience. 

For the above-mentioned reasons, currently we do not have plans to parse and keep all the pages in memory. Please let us know if you have any concerns or if our observation is different to your requirement. 

Regards, 
Divya D 



LO Lucas Oliverrothenberger June 30, 2021 06:23 PM UTC

Can there at least be a setting that we as developers can change to determine the amount of pages in memory?



DD Divya Dhayalan Syncfusion Team July 1, 2021 01:16 PM UTC

Hi Lucas, 

Currently, we do not have API for a setting to determine the number of pages in live. Based on your update, we understand that your requirement is to avoid blank pages while fast scrolling the control. As we have mentioned in our earlier update, in our current implementation to keep smooth scrolling, we start parsing the pages only when the scroll gets stopped. Can you please let us know whether increasing the number of pages in live will work for you in this case? 

This information will be helpful for us to analyze more on your requirement and provide you a better solution. 

Regards, 
Divya 



LO Lucas Oliverrothenberger July 1, 2021 01:21 PM UTC

I think increasing the number of pages would help. Our use case is for quickly looking through documents to look for key information. The people who do this are experienced in it and slowly loading the pages will slow them down however increasing the number of pages might mitigate this slowdown a little bit



DD Divya Dhayalan Syncfusion Team July 2, 2021 12:46 PM UTC

Hi Lucas, 

Thank you for providing the use case details. 
 
Currently we are analyzing on your requirement of increasing the number of pages in live and we will update further details on 6th July 2021. 
 
Regards, 
Divya 



DD Divya Dhayalan Syncfusion Team July 7, 2021 03:24 PM UTC

Hi Lucas, 

We have analyzed further on your requirement and found that we have to make some changes in our current virtualization process for providing this compatibility. We have considered and logged this request as a feature to provide “Settings to render more pages in the Virtualization process”. At the planning stage for every release cycle, we review all open features and identify features for implementation based on specific parameters including product vision, technological feasibility, and customer interest. We will let you know when this feature is implemented. 

You can track the status of this feature request here:  
 
Regards, 
Divya 


Loader.
Up arrow icon