diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2013-07-09 14:01:02 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-07-10 13:05:27 +0200 |
commit | 3dde073269b059aa238f3cd104a10d2fdb90c350 (patch) | |
tree | 4d20ada71d827f2c3f4917e6fd8b618350285dbb /src/gui/painting/qpdf.cpp | |
parent | aae0a2144d2ad62f7bdf83e5c3161e66d9a7016d (diff) |
QPdfWriter: Fix setting of paper size.
Introduce setter for converting mm to Postscript points.
Task-number: QTBUG-31443
Change-Id: I032118322657ae2a8b3b457010218d6ea3f3e720
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src/gui/painting/qpdf.cpp')
-rw-r--r-- | src/gui/painting/qpdf.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 1ca54f0432..9105e8b396 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1469,7 +1469,12 @@ int QPdfEngine::metric(QPaintDevice::PaintDeviceMetric metricType) const return val; } +static inline QSizeF pageSizeToPostScriptPoints(const QSizeF &pageSizeMM) +{ #define Q_MM(n) int((n * 720 + 127) / 254) + return QSizeF(Q_MM(pageSizeMM.width()), Q_MM(pageSizeMM.height())); +#undef Q_MM +} QPdfEnginePrivate::QPdfEnginePrivate() : clipEnabled(false), allClipped(false), hasPen(true), hasBrush(false), simplePen(false), @@ -1477,7 +1482,7 @@ QPdfEnginePrivate::QPdfEnginePrivate() fullPage(false), embedFonts(true), landscape(false), grayscale(false), - paperSize(Q_MM(210), Q_MM(297)), // A4 + paperSize(pageSizeToPostScriptPoints(QSizeF(210, 297))), // A4 leftMargin(10), topMargin(10), rightMargin(10), bottomMargin(10) // ~3.5 mm { resolution = 1200; @@ -1491,6 +1496,11 @@ QPdfEnginePrivate::QPdfEnginePrivate() stream = new QDataStream; } +void QPdfEnginePrivate::setPaperSize(const QSizeF &pageSizeMM) +{ + paperSize = pageSizeToPostScriptPoints(pageSizeMM); +} + bool QPdfEngine::begin(QPaintDevice *pdev) { Q_D(QPdfEngine); |