Going around 'Media box not found' exception when rasterizing a PDF.


I'm getting the following error when I call pdfDraw.DrawInRect. What
is causing it?

             Message: Media box not found.
             Function : PDFTRON::PDF::Page::GetMediaBox


It seems that the PDF you want to rasterize is corrupt (because the
page is missing MediaBox property, which is required accoring to PDF

To go around this call SetMediaBox() on the page before
rasterization/printing. For example.

// C#
Page page = ...
page.SetMediaBox(new PDF.Rect(0, 0, 612, 792));
pdfdraw.DrawInRect(page, ...);

// in C++
Page page = ...
page.SetMediaBox(Rect(0, 0, 612, 792));
pdfdraw.DrawInRect(page, ...);