Implementing screen grab and rectangular zooming functions.


I'm working on a screen grab function which clips an image from a
displayed PDF. The idea is that the user can zoom in/out or scroll up/
down on the pdf display and clip an image. The image is then inserted
in an html page.

The attached code (query.cpp) clips the correct region with a
particular zoom factor assuming that the user has not scrolled
horizontally or vertically. (I haven't handled the user scrolling).
The problem is that I can't seem to set the correct horizontal or
vertical scroll position. (At the minute the work around is to simply
add/subtract the horizontal/vertical position of the scroll bars in
pixels. This means that the clip region is not quite correct).

Is there something I'm missing?

1. Should I be able to set the scroll values and then call
pdfview.ConvScreenPtToPagePt? Or do I need to work out the Rect of
the clip region after scrolling by adding/subtracting the scroll
distance to the clip coordinates? If I need to compute/find the clip
region how do I convert the HScrollPos (in canvas pts?) to page pts?

2. Also should I be passing in and setting the page presentation mode
& page view mode in order to clip the correct region. (ie. would these
settings affect the clip region)??

Any advice or suggestions are much appreciated.

It seems that functionality you would like to implement is very
similar to 'Rectangular Zoom' sample code in #C PDFView sample (part
of PDFNet SDK 3.6; see
Make sure that you are using the latest version of the SDK because
there were small changes in the way pdfview.SetZoom() works
(previously the zoom point was in the top/right corner, whereas
starting with v.3.6 the zoom point is in the center of the view).

You don't need to scroll the view or to manually adjust H/VScrollPos
because all of this is automatically done in PDFView class. You also
don't need to worry about the page presentation mode & page view mode
because this should work in any mode. So you can obtain H/VScrollPos
values from PDFView class and pass them unchanged to SetScrollsPos();