summaryrefslogtreecommitdiffstats
path: root/src/printsupport/kernel/qprinter.cpp
diff options
context:
space:
mode:
authorTobias Koenig <tobias.koenig@kdab.com>2017-02-14 10:11:19 +0100
committerTobias Koenig <tobias.koenig@kdab.com>2017-03-28 07:02:05 +0000
commit6c32927f8cf226b8158dd25f4b92a6853dadb8b6 (patch)
tree7fcd1dcfa76c05d59fb6f115d133308dfe2922e2 /src/printsupport/kernel/qprinter.cpp
parent3398d9d40cb0dae2dc2a1a4f7dc3b4b9cceae903 (diff)
Improve PDF/A-1b support in QPdfWriter
Add new enum QPrinter::PdfVersion to switch QPdfWriter into PDF/A-1b mode. In that mode - meta data are embedded in XMP format - a color profile for sRGB is embedded and an OutputIntent defined - the ID key is added to the document trailer dictionary - a CIDSet entry is added to the font descriptor - transparency is removed from pens, brushes and images Change-Id: Ia8a24d83609b239e716aefc1ba05f07320dbd290 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/printsupport/kernel/qprinter.cpp')
-rw-r--r--src/printsupport/kernel/qprinter.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp
index 53bed87dfc..638187c614 100644
--- a/src/printsupport/kernel/qprinter.cpp
+++ b/src/printsupport/kernel/qprinter.cpp
@@ -147,7 +147,8 @@ void QPrinterPrivate::initEngines(QPrinter::OutputFormat format, const QPrinterI
printEngine = ps->createNativePrintEngine(printerMode);
paintEngine = ps->createPaintEngine(printEngine, printerMode);
} else {
- QPdfPrintEngine *pdfEngine = new QPdfPrintEngine(printerMode);
+ const auto pdfEngineVersion = (pdfVersion == QPrinter::PdfVersion_1_4 ? QPdfEngine::Version_1_4 : QPdfEngine::Version_A1b);
+ QPdfPrintEngine *pdfEngine = new QPdfPrintEngine(printerMode, pdfEngineVersion);
paintEngine = pdfEngine;
printEngine = pdfEngine;
}
@@ -685,7 +686,37 @@ QPrinter::OutputFormat QPrinter::outputFormat() const
return d->outputFormat;
}
+/*!
+ \since 5.10
+
+ Sets the PDF version for this printer to \a version.
+
+ If \a version is the same value as currently set then no change will be made.
+*/
+void QPrinter::setPdfVersion(PdfVersion version)
+{
+ Q_D(QPrinter);
+
+ if (d->pdfVersion == version)
+ return;
+
+ d->pdfVersion = version;
+ if (d->outputFormat == QPrinter::PdfFormat) {
+ d->changeEngines(d->outputFormat, QPrinterInfo());
+ }
+}
+
+/*!
+ \since 5.10
+
+ Returns the PDF version for this printer. The default is \c PdfVersion_1_4.
+*/
+QPrinter::PdfVersion QPrinter::pdfVersion() const
+{
+ Q_D(const QPrinter);
+ return d->pdfVersion;
+}
/*! \internal
*/