diff options
author | Trond Kjernåsen <trond.kjernasen@nokia.com> | 2010-04-23 10:14:43 (GMT) |
---|---|---|
committer | Trond Kjernåsen <trond.kjernasen@nokia.com> | 2010-04-23 10:19:55 (GMT) |
commit | b5b096996de656dc44723b02826d892291173797 (patch) | |
tree | 15bf6de7cdb59124b1b89b583108bdebaebf89e3 /src/gui/painting/qprintengine_ps.cpp | |
parent | cde4ad3db7c673ca8ba5457c12a8b04dfbbf99aa (diff) | |
download | Qt-b5b096996de656dc44723b02826d892291173797.zip Qt-b5b096996de656dc44723b02826d892291173797.tar.gz Qt-b5b096996de656dc44723b02826d892291173797.tar.bz2 |
Fixed two problems with generated EPS files.
1. The Adobe EPSF 3.0 spec requires that the PS version of EPS files is
PS-Adobe-3.0.
2. The %%BoundingBox operator is documented to use integers, we used
to output floating point numbers when generating an EPS file.
Task-number: QTBUG-10121, QTBUG-10140
Reviewed-by: Kim
Diffstat (limited to 'src/gui/painting/qprintengine_ps.cpp')
-rw-r--r-- | src/gui/painting/qprintengine_ps.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/gui/painting/qprintengine_ps.cpp b/src/gui/painting/qprintengine_ps.cpp index ac94de3..28e9a7a 100644 --- a/src/gui/painting/qprintengine_ps.cpp +++ b/src/gui/painting/qprintengine_ps.cpp @@ -485,7 +485,6 @@ void QPSPrintEnginePrivate::emitHeader(bool finished) QByteArray header; QPdf::ByteStream s(&header); - s << "%!PS-Adobe-1.0"; qreal scale = 72. / ((qreal) q->metric(QPaintDevice::PdmDpiY)); QRect pageRect = this->pageRect(); @@ -497,28 +496,32 @@ void QPSPrintEnginePrivate::emitHeader(bool finished) int width = pageRect.width(); int height = pageRect.height(); if (finished && pageCount == 1 && copies == 1 && - ((fullPage && qt_gen_epsf) || (outputFileName.endsWith(QLatin1String(".eps")))) - ) { + ((fullPage && qt_gen_epsf) || (outputFileName.endsWith(QLatin1String(".eps"))))) + { + // According to the EPSF 3.0 spec it is required that the PS + // version is PS-Adobe-3.0 + s << "%!PS-Adobe-3.0"; if (!boundingBox.isValid()) boundingBox.setRect(0, 0, width, height); if (orientation == QPrinter::Landscape) { if (!fullPage) boundingBox.translate(-mleft, -mtop); s << " EPSF-3.0\n%%BoundingBox: " - << (int)(printer->height() - boundingBox.bottom())*scale // llx - << (int)(printer->width() - boundingBox.right())*scale - 1 // lly - << (int)(printer->height() - boundingBox.top())*scale + 1 // urx - << (int)(printer->width() - boundingBox.left())*scale; // ury + << int((printer->height() - boundingBox.bottom())*scale) // llx + << int((printer->width() - boundingBox.right())*scale - 1) // lly + << int((printer->height() - boundingBox.top())*scale + 1) // urx + << int((printer->width() - boundingBox.left())*scale); // ury } else { if (!fullPage) boundingBox.translate(mleft, -mtop); s << " EPSF-3.0\n%%BoundingBox: " - << (int)(boundingBox.left())*scale - << (int)(printer->height() - boundingBox.bottom())*scale - 1 - << (int)(boundingBox.right())*scale + 1 - << (int)(printer->height() - boundingBox.top())*scale; + << int((boundingBox.left())*scale) + << int((printer->height() - boundingBox.bottom())*scale - 1) + << int((boundingBox.right())*scale + 1) + << int((printer->height() - boundingBox.top())*scale); } } else { + s << "%!PS-Adobe-1.0"; int w = width + (fullPage ? 0 : mleft + mright); int h = height + (fullPage ? 0 : mtop + mbottom); w = (int)(w*scale); |