KaptainKarl
20th October 2014, 15:20
Qt Version: 5.3.1
OS: CentOS 6.5
I'm attempting to create a PDF report using QPainter.
This seems to work better than using QTextDocument.
However, I am faced with an issue involving certain graphics files when I attempt to load them.
I have a JPEG file that contains a company logo (attached). When loaded in the GNOME image viewer, the tool indicates the image is 170 pixels x 80 pixels.
I have attempted to use QPixmap and QImage as the mechanism for loading and putting the image into the QPainter object that then dump to PDF.
Here is the issue:
The QPixmap method produces an image that is extremely small in the PDF file. If I attempt to scale it up, the image quality becomes very poor.
The QImage method produces no image in the PDF file.
Here is the code:
#include <QApplication>
#include <QPdfWriter>
#include <QPainter>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QPdfWriter pdfWriter("my.pdf");
QPainter painter(&pdfWriter);
quint32 iYPos = 10;
QPixmap pxPic;
pxPic.load("/usr/local/SMART/public_html/images/logo.jpg", "JPG");
painter.drawPixmap(0, iYPos, pxPic.width(), pxPic.height(), pxPic);
iYPos += pxPic.height() + 250;
QImage imgPic;
imgPic.load("/usr/local/SMART/public_html/images/logo.jpg", "JPG");
painter.drawImage(0, iYPos, imgPic, imgPic.width(), imgPic.height());
return 0;
}
I would appreciate any input as to how to make this work.
Karl
OS: CentOS 6.5
I'm attempting to create a PDF report using QPainter.
This seems to work better than using QTextDocument.
However, I am faced with an issue involving certain graphics files when I attempt to load them.
I have a JPEG file that contains a company logo (attached). When loaded in the GNOME image viewer, the tool indicates the image is 170 pixels x 80 pixels.
I have attempted to use QPixmap and QImage as the mechanism for loading and putting the image into the QPainter object that then dump to PDF.
Here is the issue:
The QPixmap method produces an image that is extremely small in the PDF file. If I attempt to scale it up, the image quality becomes very poor.
The QImage method produces no image in the PDF file.
Here is the code:
#include <QApplication>
#include <QPdfWriter>
#include <QPainter>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QPdfWriter pdfWriter("my.pdf");
QPainter painter(&pdfWriter);
quint32 iYPos = 10;
QPixmap pxPic;
pxPic.load("/usr/local/SMART/public_html/images/logo.jpg", "JPG");
painter.drawPixmap(0, iYPos, pxPic.width(), pxPic.height(), pxPic);
iYPos += pxPic.height() + 250;
QImage imgPic;
imgPic.load("/usr/local/SMART/public_html/images/logo.jpg", "JPG");
painter.drawImage(0, iYPos, imgPic, imgPic.width(), imgPic.height());
return 0;
}
I would appreciate any input as to how to make this work.
Karl