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>
bb10
Andre de la Rocha 2019-01-08 13:00:46 +01:00 committed by Jani Heikkinen
parent 5feac1e10c
commit 81c3c66bb4
1 changed files with 4 additions and 3 deletions

View File

@ -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");