summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndre de la Rocha <andre.rocha@qt.io>2019-01-08 13:00:46 +0100
committerJani Heikkinen <jani.heikkinen@qt.io>2019-01-08 16:35:03 +0000
commit81c3c66bb44c98b29a0181450ffa38a1c1fa06d9 (patch)
tree763320c8b9d793665ad3d8e1c80d9e87fbb030cb /src
parent5feac1e10cfb95e2d17658b7a1611052a4ff8d17 (diff)
Fix PDF generation for locales using comma as decimal separator
A previous change that extended the maximum PDF size has caused the generation of invalid PDF output when the current locale was set to something using commas instead of points when outputting floating point numbers through printf(). This change uses QByteArray::number() instead, which uses points, irrespective of the current locale. Fixes: QTBUG-72868 Fixes: QTBUG-72848 Change-Id: I292eba2d6c89b3e01957bb8c04c04bdca8ada316 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Tobias Koenig <tobias.koenig@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/painting/qpdf.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp
index e69726b617..ae3df6f9ec 100644
--- a/src/gui/painting/qpdf.cpp
+++ b/src/gui/painting/qpdf.cpp
@@ -1953,13 +1953,14 @@ void QPdfEnginePrivate::writePage()
"/Contents %d 0 R\n"
"/Resources %d 0 R\n"
"/Annots %d 0 R\n"
- "/MediaBox [0 0 %f %f]\n",
+ "/MediaBox [0 0 %s %s]\n",
pageRoot, pageStream, resources, annots,
// make sure we use the pagesize from when we started the page, since the user may have changed it
- currentPage->pageSize.width() / userUnit, currentPage->pageSize.height() / userUnit);
+ QByteArray::number(currentPage->pageSize.width() / userUnit, 'f').constData(),
+ QByteArray::number(currentPage->pageSize.height() / userUnit, 'f').constData());
if (pdfVersion >= QPdfEngine::Version_1_6)
- xprintf("/UserUnit %f\n", userUnit);
+ xprintf("/UserUnit %s\n", QByteArray::number(userUnit, 'f').constData());
xprintf(">>\n"
"endobj\n");