Selecting, rendering, and exporting a subregion of a PDF page.

Q: I'm working with image-based (scanned) PDF documents and I need to
develop a function that allows me to select a rectangular portion of
the page and save the contents of the selected area to a TIFF file.
I'm easily able to select an entire page and export it to an image
file, however I'm having difficulity saving only the selected portion
of the page to an image. I've searched all the sample code and also
visited the support group on Google, but I'm not able to find enough
hints on how to accomplish this. Any code samples or suggestions you
could forward would be appreciated would be appreciated.
------
A: Perhaps the simplest way to render a subset of a PDF page is to set
a crop box before passing the page to PDFDraw. For example:

Rect old_crop = page.GetCropBox();
page.SetCropBox(region_rect);
pdfdraw.Export(....);

After you export the page you may want to restore the previous clip
region using

page.SetCropBox(old_crop);

For a concrete sample code please take a look at example 5 in PDFDraw
sample: http://www.pdftron.com/net/samplecode.html#PDFDraw

Also if you are extending PDFView sample project with this
functionality, make sure that you lock the document before reading or
writing the PDF document.

_pdfdoc.Lock();
.....
_pdfdoc.Unlock();

This will prevent possible collision between the render thread and
your own thread.

The only remaining question is how to implement a user mode tool to
allow the user to select a region (i.e. region_rect in the above code)
of PDF page for export. For a concrete example of how to implement
this functionality you may want to take a look at the impementation of
'rectangular zoom', and 'Link create' tools in PDFView sample