Loading multiples pages with WebPackageReader

Jul 30, 2010 at 5:31 PM

Hi Folks,

 

For a custom development, we have to display a xps document in a book style control. We tried to load multiple pages of a xps document with WebPackageReader, but it doesn't works.

According to the fact that the FixedPageViewer load pages of the xps document only when it displayed, we want to preload n previous and next pages not to wait.

 

 

 

 

 

Coordinator
Aug 1, 2010 at 2:38 PM

Hi,

Did you take a look at the BookSample available in the SampleBrowser project? The BookSample uses a local SharpZipPackageReader which can easily be replaced by a WebPackageReader. The included BookBehavior ensures the correct pages are loaded and also handle multiple page loads.

- Koen

Aug 2, 2010 at 2:50 PM

Hi,

 

I already tried to modify Mitsu's Book Control with a WebPackageReader, the problem is still here, the loading of next and previous pages is really slow. Is there a way to preload the n next and previous pages (which are not displayed) in order to reduce the load time when flipping pages ?

 

 

Coordinator
Aug 2, 2010 at 3:21 PM

You can add preloading in the BookBehavior like this; when a page is requested using the GetItem(int index), you should set the PageContext.IsInUse to true for the desired number of pages you want to preload. 

Example:

var pageControl = this.pageControls.ElementAtOrDefault(index);
if (pageControl != null) {
    var pageContext = (PageContext)pageControl.DataContext;
    pageContext.IsInUse = true;     // ensure page is loaded
}

foreach(var pageContext in this.pageCollection){
    var pageIndex = pageContext.PageContent.PageNumber - 1;

    if (pageIndex < index - 5 || pageIndex > index + 3) {
        // unload invisible pages
        pageContext.IsInUse = false;
    }
    else {
        // preload page
        pageContext.IsInUse = true;
    }
}

Jul 16, 2014 at 4:56 AM
Edited Jul 16, 2014 at 6:37 AM
kozw wrote:
You can add preloading in the BookBehavior like this; when a page is requested using the GetItem(int index), you should set the PageContext.IsInUse to true for the desired number of pages you want to preload.  Example: var pageControl = this.pageControls.ElementAtOrDefault(index); if (pageControl != null) { var pageContext = (PageContext)pageControl.DataContext; pageContext.IsInUse = true; // ensure page is loaded } foreach(var pageContext in this.pageCollection){ var pageIndex = pageContext.PageContent.PageNumber - 1; if (pageIndex < index - 5 || pageIndex > index + 3) { // unload invisible pages pageContext.IsInUse = false; } else { // preload page pageContext.IsInUse = true; } }
Hi,
I have the same problem,too. But I try to set pageContext.IsInUse=true; it's not work. When flipping pages use Fiddler web debugger to monitor I found document toolkit always one time load 6 pages . How to change this one time read count? Is there a way let WebPackageReader continue loading pages when flipping pages .