From 81c3c66bb44c98b29a0181450ffa38a1c1fa06d9 Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Tue, 8 Jan 2019 13:00:46 +0100 Subject: 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 Reviewed-by: Tobias Koenig --- src/gui/painting/qpdf.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') 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"); -- cgit v1.2.3