summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Kjernåsen <trond@trolltech.com>2010-01-15 09:28:34 (GMT)
committerTrond Kjernåsen <trond@trolltech.com>2010-01-15 09:28:34 (GMT)
commit9ba9308a997bac90c30b766a48f44451e86e14d9 (patch)
treeb09a78dd992a87fb105aad0375ae933cf290d114
parent8f3277d808e2f77661df0e28dfb8f4c6025258cb (diff)
downloadQt-9ba9308a997bac90c30b766a48f44451e86e14d9.zip
Qt-9ba9308a997bac90c30b766a48f44451e86e14d9.tar.gz
Qt-9ba9308a997bac90c30b766a48f44451e86e14d9.tar.bz2
Fixed the encoding of the Tile and Creator tags in the PDF engine.
Task-number: QTBUG-7249 Reviewed-by: Kim
-rw-r--r--src/gui/painting/qprintengine_pdf.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/gui/painting/qprintengine_pdf.cpp b/src/gui/painting/qprintengine_pdf.cpp
index e3a2461..b8bf15e 100644
--- a/src/gui/painting/qprintengine_pdf.cpp
+++ b/src/gui/painting/qprintengine_pdf.cpp
@@ -931,14 +931,24 @@ void QPdfEnginePrivate::writeHeader()
void QPdfEnginePrivate::writeInfo()
{
info = addXrefEntry(-1);
- xprintf("<<\n"
- "/Title (%s)\n"
-// "/Author (%s)\n"
- "/Creator (%s)\n"
- "/Producer (Qt " QT_VERSION_STR " (C) 2009 Nokia Corporation and/or its subsidiary(-ies))\n",
- title.toUtf8().constData(),
-// author.toUtf8().constData(),
- creator.toUtf8().constData());
+
+ // The 'text string' type in PDF is encoded either as PDFDocEncoding, or
+ // Unicode UTF-16 with a Unicode byte order mark as the first character
+ // (0xfeff), with the high-order byte first.
+ QByteArray array("<<\n/Title (\xfe\xff");
+ const ushort *utf16Title = title.utf16();
+ for (int i=0; i < title.size(); ++i) {
+ array.append((*(utf16Title + i)) >> 8);
+ array.append((*(utf16Title + i)) & 0xff);
+ }
+ array.append(")\n/Creator (\xfe\xff");
+ const ushort *utf16Creator = creator.utf16();
+ for (int i=0; i < creator.size(); ++i) {
+ array.append((*(utf16Creator + i)) >> 8);
+ array.append((*(utf16Creator + i)) & 0xff);
+ }
+ array.append(")\n/Producer (Qt " QT_VERSION_STR " (C) 2010 Nokia Corporation and/or its subsidiary(-ies))\n");
+ write(array);
QDateTime now = QDateTime::currentDateTime().toUTC();
QTime t = now.time();