Is this possible to force render only necessary region of PDFViewCtrl ? (Winrt)

In our app we tested PDFNet SDK for WinRT.

We need to present pdf as a one of our layers:

    <Our second layer>
    <Our third layer>
    <Can be more than 5 layers>

And zooming will be implemented by "ScrollViewer".

The problem is: when we zoom, the actual width/height of ScrollViewer doesn't changed (changed only zoom factor). And PDFViewCtrl think that it is the same size as on start and not render automatically.

Is this possible to force render only necessary region of PDFViewCtrl or just force render PDFViewCtrl with specified DPI?

note: we worked only with single page pdf documents.

Hi Андрей Жуковский,

What you are attempting to do is very difficult. I haven’t tried it myself, and I’m not sure how the PDFViewCtrl would react to being inside a scroll viewer. You can’t make it render at a certain DPI. You could however change it’s size and then user a scale transform to bring it back to the desired size. I don’t know if there will be an problems with scaling the content, since the scale your put on it would counteract the scale of the scroll viewer. I believe the operating system would take care of that, and I don’t know how it will perform visually. There would still be a problem of what region of the PDF to render, as the PDFViewCtrl atuomatically renders whatever is closest to the viewport first. In your scenario, the PDFViewCtrl will be large enough to contain the entire PDFViewCtrl, so it would try to render it all. It’s not designed to be of dimensions larger than a screen, so if the document is too large, it won’t be able to render the whole thing.

Another thing you might consider doing is using PDFDraw (you can check the PDFDrawTest in the PDFNetWinRTSamples project) instead of the PDFViewCtrl.

Finally, it might be worth considering using the PDFViewCtrl as the scroll viewer, and then put extra layers on top of that.
You can use PDFViewCtrl.GetAnnotationCanvas() to get a canvas on which you can put your content. The AnnotationCanvas is the one the tools are using, and so it is always the size of the content inside the PDFViewCtrl. The trick here is that the PDFViewCtrl resets the scale of the internal ScrollViewer after a zoom action, so you will have to listen to the OnScale (also, OnSize and OnLayoutChanged) event of the PDFViewCtrl and resize your content to line up on top of the PDFViewCtrl content. Could take a look at Tool.cs and how DrawSelection and it’s surrounding functions work to make this happen with text selection in the current tools code. That way of doing things might work for you.

Just keep in mind that if you’re in a non-continuous mode, then every time you change to a new page (or new pair of pages in facing) they will have a different AnnotaitonCanvas, so you have to call PDFViewCtrl.GetAnnotationCanvas() again every time a page changes in that view mode.

Best Regards,
Tomas Hofmann