# How to handle images in a proper way by rendering from QPdfDocument

• Dear all,

I want to extract an image from a PDF document. The PDF document page is the following:

using the QPdfDocument class I rendered an image using

QPdfDocument pdf;
const int n = 0;
QImage qimg = pdf.render(n,pdf.pageSize(n).toSize());
qimg = qimg.convertToFormat(QImage::Format_RGB888);

The rendered image looks like:

Extracting the image's alpha channel by using

QImage alpha = qimg.convertToFormat(QImage::Format_Alpha8);
alpha.invertPixels(QImage::InvertRgba);

I get:

As mentioned in an earlier post I just want to render an image of the PDF page that looks the same as the pdf page itsself, no fancy stuff. I guess I somehow have to combine or convert the upper both images. I'd be grateful if someone has an idea of how to get things done.

Cheers