Help with PDFRasterizer

Q: I know the following example can be done easily with PdfDraw, but I
need to get this working with the PDFRasterizer. I've attached a
simple PDF and the image the was generated using the following code

using (Bitmap bitmap = new Bitmap((int)(500), (int)(500)))
   bitmap.SetResolution(100, 100);
   using (Graphics graphics = Graphics.FromImage(bitmap))
      IntPtr hdc = graphics.GetHdc();
         PDFRasterizer rasterizer = new PDFRasterizer
         rasterizer.Rasterize(page, hdc, null, null, 0);

The page object is got from with your PDFView sample code using;

PDFDoc pdfdoc = GetPDFDoc();
Page page = pdfdoc.GetPage(_pdfview.GetCurrentPage());

The rendered image is ok, but is flipped vertically. I'm obviously
missing a rotation/transformation but for the life of me I cant find
it. Any help would be greatly appreciated. Any sample code on the use
of the PDFRasterizer also appreciated.

A: You need to pass in the device matrix as the third parameter in the
call to Rasterize(). You could use page.GetDefaultMatrix() and
multiply it with whatever scaling factor you need. If you would like
to flip/mirror the output image, simply pass 'true' as the first
parameter. For example:

  Matrix2D my_matrix = new Matrix2D(1, 0, 0, 1, 0, 0);
  rasterizer.Rasterize(page, hdc, my_matrix * page.GetDefaultMatrix
(true), null, 0);

Please keep in mind that you can also render into an HDC using
pdftron.PDF.PDFDraw class (i.e. pdfdraw.DrawInRect(IntPtr hdc, ...)).
In most cases PDFDraw is simpler to use than PDFRasterizer.

Q: Thanks, I'll give that a try.
I have large pdfs and only need a small section. 50"x50" pdf. And, for
example, I might just want 1"x1" from the centre converted into a
bitmap. I've tried using pdfdraw but as soon as I use a large dpi it
seems to run out of memory. I think I was using GetBitmap though.
Is there a way I should be doing this without using the PDFRasterizer?
A: To draw a subset of a page you could call page.SetCropBox(box)
before drawing the page. This is illustrated at the end of PDFDraw
sample project (