Qt: Printing pageRect and paperRect issues

Posted by Pavels on Stack Overflow See other posts from Stack Overflow or by Pavels
Published on 2009-05-27T13:41:45Z Indexed on 2010/06/08 18:42 UTC
Read the original article Hit count: 316

Filed under:
|

I have following printing code:

void Print(QPrinter *printer)
{
    QPainter q(printer);
    q.setRenderHint(QPainter::HighQualityAntialiasing, true);

    q.setPen(QPen(QColor("red")));
    q.drawRect(printer->pageRect());
    q.drawLine(printer->pageRect().topRight(), printer->pageRect().bottomLeft());

    q.setPen(QPen(QColor("blue")));
    q.drawRect(printer->paperRect());
    q.drawLine(printer->paperRect().topRight(), printer->paperRect().bottomLeft());
}

The result is different with QPrintPreviewDialog, rendered PDF, output to printers (HP LaserJet, PdfFactory, PdfCreator). Most of time the resulting rectangle is out of paper. What to do so the output is similar to all printers?

© Stack Overflow or respective owner

Related posts about qt

Related posts about printing