ChrisW67
4th September 2009, 03:28
Hi All,
I'm having a bit of fun with cross-platform differences in printing. I use QPrinter::setFullPage() to allow me to place a full-page sized template of a complex form (from an SVG file) on the page. On Linux it works fine. On Windows the template image is offset because, apparently, full page does not mean that on Windows (except when the print is directed to PDF). This test code:
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPrinter p(QPrinter::HighResolution);
p.setPaperSize(QPrinter::A4);
p.setOrientation(QPrinter::Landscape);
p.setFullPage(true);
qDebug() << "Page rect: " << p.pageRect();
qDebug() << "Paper rect: " << p.paperRect();
QWidget mainWin;
mainWin.show();
return app.exec();
}
On Linux prints:
Page rect: QRect(0,0 14033x9917)
Paper rect: QRect(0,0 14033x9917)
as the docs imply, and Windows:
Page rect: QRect(99,99 6814x4760)
Paper rect: QRect(0,0 7016x4961)
Firstly, can others confirm this behaviour? Secondly, is the only way around this to let Windows have its ~5mm border* all round, force the same on Linux, and shrink my template accordingly?
* Actually it will have to be at least as large as the largest printer border the app is likely to encounter because I guess the figures come from the printer driver on Windows.
I'm having a bit of fun with cross-platform differences in printing. I use QPrinter::setFullPage() to allow me to place a full-page sized template of a complex form (from an SVG file) on the page. On Linux it works fine. On Windows the template image is offset because, apparently, full page does not mean that on Windows (except when the print is directed to PDF). This test code:
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPrinter p(QPrinter::HighResolution);
p.setPaperSize(QPrinter::A4);
p.setOrientation(QPrinter::Landscape);
p.setFullPage(true);
qDebug() << "Page rect: " << p.pageRect();
qDebug() << "Paper rect: " << p.paperRect();
QWidget mainWin;
mainWin.show();
return app.exec();
}
On Linux prints:
Page rect: QRect(0,0 14033x9917)
Paper rect: QRect(0,0 14033x9917)
as the docs imply, and Windows:
Page rect: QRect(99,99 6814x4760)
Paper rect: QRect(0,0 7016x4961)
Firstly, can others confirm this behaviour? Secondly, is the only way around this to let Windows have its ~5mm border* all round, force the same on Linux, and shrink my template accordingly?
* Actually it will have to be at least as large as the largest printer border the app is likely to encounter because I guess the figures come from the printer driver on Windows.