this code outputs pdf from html:
QTextDocument doc; doc.setHtml("<h1>hello, I'm an head</h1>"); QPrinter printer; printer.setOutputFileName("c:\\temp\\file.pdf"); printer.setOutputFormat(QPrinter::PdfFormat); doc.print(&printer); printer.newPage();
I think you can create a html wrapper for your img and quickly print your image. Otherwise, you can copy the image directly to the printer, as this is a drawing device in a similar way.
QPrinter printer; QPainter painter(&printer); printer.setOutputFileName("c:\\temp\\file.pdf"); printer.setOutputFormat(QPrinter::PdfFormat); painter.drawImage(QRect(0,0,100,100), <QImage loaded from your file>); printer.newPage();
Max lambertini
source share