I need to write my own pdf viewer (UserControl). I use pdfium.dll for that. The wrapper of it is PdfiumService. This service can render pages to BitmapSource. PdfViewer displays pages in VirtualizingStackPanel in ScrollViewer. Any ideas how can I do lazy render for pdf? The problem is if pdf is about 20mb (1000 pages), rendered pages take about 2gb RAM.
Can VirtualizingStackPanel help me? I didn't find any events for "BeginVirtualizing" or something else. Any easy ways to know what item is displaying now?
Maybe something like that:
- Calculate how many pages can be displayed at once.
- See ScrollViewer's offset.
- Calculate the index of page is now displaying.
- Render 5 pages next to current.
Are there any ready solutions, or some tips, or ideas for this?