Hi, I need to use QPrinter to generate a PDF doc with several images (one image for page). I use the code below to generate a PDF doc with one image in one page, the problem is that the size of the resulting doc is extremely big (7 MB
). I've tried to set the resolution to the minimum resolution (72dpi) that supports the printer driver (PDFCreator) and the printer mode to "ScreenResolution" but it doesn't works. I also have tried to set to the maximum compresion of images in PDFCreator but it neither works. Very strange. Somebody could suggest me something else? Thanks.
int main(int argc, char *argv[])
{
printer.setResolution(72);
printer.
setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName("../test.pdf");
printer.setFullPage( TRUE );
printer.
setOrientation(QPrinter::Landscape);
painter.begin(&printer);
painter.
drawImage(printer.
pageRect(),
QImage("../proba.jpg");
painter.end();
return 0;
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QPrinter printer(QPrinter::ScreenResolution);
printer.setResolution(72);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName("../test.pdf");
printer.setFullPage( TRUE );
printer.setPageSize(QPrinter::A4);
printer.setOrientation(QPrinter::Landscape);
QPainter painter;
painter.begin(&printer);
painter.drawImage(printer.pageRect(), QImage("../proba.jpg");
painter.end();
return 0;
}
To copy to clipboard, switch view to plain text mode
PD: The original size of the test image ("proba.jpg") is 3368x2440 pix and it's in grayscale. But I also have tried to set the colorMode of the printer to graysCale but the resulting size is always the same
Bookmarks