jiveaxe
11th January 2008, 15:13
Hi,
these are my 2 question?
1)
I have added "print to pdf" to my program; here the function:
void MainWindow::printToPdf()
{
QPrinter printer;
printer.setOrientation(QPrinter::Portrait);
printer.setOutputFileName("test.pdf");
printer.setOutputFormat(QPrinter::PdfFormat);
QImage image(700,1000,QImage::Format_ARGB32);
QPainter painter;
painter.setRenderHint(QPainter::Antialiasing, true);
painter.begin(&image);
// Draw some text to image
painter.end();
QPainter p;
p.begin(&printer);
p.drawImage(0, 0, image);
p.end();
}
When I click the first time on the print button the pdf is created in the right way, but if I click a second time the resulting pdf shows some ugly effects: or the contents of the two print actions overlaps or are present some black dots and lines (apart from the desired text).
I have also added delete &painter, delete &printer, delete &image at the end of the above code but I got segmentation fault calling the print function.
2)
If I have two qimage is it possible print a pdf with two pages, one for each qimage?
Thanks
these are my 2 question?
1)
I have added "print to pdf" to my program; here the function:
void MainWindow::printToPdf()
{
QPrinter printer;
printer.setOrientation(QPrinter::Portrait);
printer.setOutputFileName("test.pdf");
printer.setOutputFormat(QPrinter::PdfFormat);
QImage image(700,1000,QImage::Format_ARGB32);
QPainter painter;
painter.setRenderHint(QPainter::Antialiasing, true);
painter.begin(&image);
// Draw some text to image
painter.end();
QPainter p;
p.begin(&printer);
p.drawImage(0, 0, image);
p.end();
}
When I click the first time on the print button the pdf is created in the right way, but if I click a second time the resulting pdf shows some ugly effects: or the contents of the two print actions overlaps or are present some black dots and lines (apart from the desired text).
I have also added delete &painter, delete &printer, delete &image at the end of the above code but I got segmentation fault calling the print function.
2)
If I have two qimage is it possible print a pdf with two pages, one for each qimage?
Thanks