Problem with image in PDF using QTextDocument.
-
wrote on 21 Dec 2012, 08:11 last edited by
I'm using QTextDocument to print PDF file from HTML. But, the image was broken in the PDF file.
This is HTML syntax:
@<html><head></head><body><img src="file:///home/user/Pictures/avatar.jpg"></body></html>@And my Qt/C++ code is:
@QPrinter printer;
printer.setOrientation(QPrinter::Portrait);
printer.setPaperSize(QPrinter::A4);
printer.setResolution(300);
printer.setFullPage(true);
printer.setCopyCount(1);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(location);QTextDocument document;
document.setHtml(htmlText);
document.print(&printer);@How can I fix this?
-
wrote on 25 Dec 2012, 11:34 last edited by
Try using Portable Network Graphics (.png) instead of JPEGs. I had several problems with JPEGs, too, and using PNGs fixed the problem.
To convert your image, you could use any image manipulation program (e.g. GIMP), load the image and export it as Portable Network Graphic.
1/2