The first image printed to PDF is invisible
I’ve been developing an application which user can design a page and print it. My printer function works like this:
- // some code to configure the printer
- // some code to paint the pages
And the function that I use to print the images is
The first image that I printed to PDF file becomes invisible. When I print a copy of the same image to the same PDF file, it becomes visible. So the problem is only for the first copy of the image, when I paint the the same image second time or third time there is no problem.(These are not the same QPixmap objects. These are different QPixmap objects which are created from the same image file.) After painting an image, if I paint a different image for the first time, it also appears invisible.
I’ve spent a lot of time to solve the problem but still couldn’t find the solution.
I would appreciate any suggestions please.
Do you have a small example project that shows this issue for us to play with?
This does sound very much like a bug to me, so maybe you should file it here [bugreports.qt.nokia.com]. A small example project attached to the report will help a lot to fix the issue as the developers will take way less time to reproduce the issue.
I’ve found that the problem appears when I set the brush to Qt::transparent before painting the pixmap.
- painter.drawPixmap(0, 0, 100, 100, QPixmap("sample.png"));
- painter.drawPixmap(200, 0, 100, 100, QPixmap("sample.png"));
- painter.drawPixmap(0, 100, 100, 100, QPixmap("sample2.png"));
- painter.drawPixmap(200, 100, 100, 100, QPixmap("sample2.png"));
Only the second sample.png and the second sample2.png will be visible.