Using PDFNet for C++ with QT (PDFDraw to QPixmap)

Q: I am considering using PDFNet SDK as a replacement to poppler.

I have a working app with poppler but am not happy with the
‘experimental’ arthur (for Qt) support and all the library

I am using Qt and have my own widgets and such setup, all I need to do
is use pdfdraw to create a pixmap and I have my own ‘view’ widgets.

Can you recommend the most efficient way to create a QPixmap on demand
from pdfdraw?

A: Instead of using pdftron.PDF.PDFDraw it is probably a better idea
to base your QT viewer on pdftron.PDF.PDFView class. An example of
PDFView integration is PDFView sample project (in PDFNet for C++ /
Windows version). In this sample PDFView is used to render PDF in an
MFC application, however the same approach would work in any other
framework (QT, wXWidgets etc).

In case you would like to use PDFView class QT, you would need to
provide a callback function that would be invoked on every paint/zoom/
scroll event (see SetRenderBeginProc/SetRenderFinishProc() in
OnInitialUpdate() method in PDFViewView.cpp file (part of PDFView
sample project). Creating a wrapper for PDFView is not a one liner,
however in the long run it should be much simpler than writing a full
control from scratch.

In case you have very specific requirements that PDFView can’t meet
you could use PDFDraw to render the image for QPixmap. In this case
you could use PDFDraw.GetBitmap(…) method as shown in PDFDrawTest

int width, height, stride;
double dpi;
const UChar* buf = draw.GetBitmap(page, width, height, stride, dpi,

You can use this to initialize QImage using one of the following


It seems like you can create QPixmap from QImage (using fromQImage)?