Qt: Printing pageRect and paperRect issues
- by Pavels
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?