What is the fastest way to render PDF with PDFDraw.GetBitmap()? - to capture image in PDFViewCtrl

Q: In doing some performance analysis of the application we have which uses the PDFTron PDFNet SDK, I have found that the GetBitmap() call on the PDFDraw object is considerably slow compared to most other processing.

We take image captures of small areas of a PDF in the PDFViewCtrl as follows. If you have any suggestions on how to streamline things so the GetBitmap() call can be faster while not significantly compromising quality, please let me know. Otherwise, I am considering ways to do screen captures to the Windows clipboard of the selected area to see if that will be much faster:

Bitmap bitmap = null;

using (PDFDraw drawer = new PDFDraw(300)) // Reducing DPI from 300 to 96 doesn’t seem to improve performance much but reduces quality of image significantly


//looks like it doesn’t add too much performance, can even be slower

/*if (useGDIRasterizer)




//drawer.SetImageSmoothing(false); // Don’t believe this is relevant for operation at hand


page.SetBox(Page.Box.e_trim, new Rect(x1, y1, x2, y2));


loadedDoc.Lock(); // necessary to avoid exceptions from conflicts with rendering thread

bitmap = drawer.GetBitmap(page); // This call can take 300ms or more




PDF Rendering is one of the most computationally expensive operation with PDF.

You can improve performance if you set the crop instead of the trim box:

page.SetBox(Page.Box.e_crop, new Rect(x1, y1, x2, y2));

The performance should improve with the decreasing size of the crop rectangle.

If you are capturing at screen resolution you can set dpi to be [72 * pdfview.GetZoom()] instead of hardcoding DPI to 300.

Finally if you only need to capture what is visible on the screen you can probably use some WIN32 or .NET technique (e.g. by overriding control’s OnPaint() or similar) to capture the content of PDFViewCtrl. This would be fastest since it would completely avoid re-rasterizing PDF.