From 9d6b4d11424cdcd6c572cdcc50b3b790b6e673c0 Mon Sep 17 00:00:00 2001 From: Jordi Pujol Foyo Date: Fri, 13 Dec 2019 14:27:11 +0100 Subject: New features for QPdfWriter Added new API setDocumentXmpMetadata/documentXmpMetadata and addFileAttachment [ChangeLog][QtGui][QPdfWriter] New API to provide external document XMP metadata and attach files to PDF. Fixes: QTBUG-78651 Fixes: QTBUG-78764 Change-Id: Ic0b37e8d12899f907001db469080594c14c87655 Reviewed-by: Eirik Aavitsland --- src/gui/painting/qpdfwriter.cpp | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'src/gui/painting/qpdfwriter.cpp') diff --git a/src/gui/painting/qpdfwriter.cpp b/src/gui/painting/qpdfwriter.cpp index 35814d146c..4f70fe6ad2 100644 --- a/src/gui/painting/qpdfwriter.cpp +++ b/src/gui/painting/qpdfwriter.cpp @@ -266,6 +266,50 @@ int QPdfWriter::resolution() const return d->engine->resolution(); } +/*! + \since 5.15 + + Sets the document metadata. This metadata is not influenced by the setTitle / setCreator methods, + so is up to the user to keep it consistent. + \a xmpMetadata contains XML formatted metadata to embed into the PDF file. + + \sa documentXmpMetadata() +*/ + +void QPdfWriter::setDocumentXmpMetadata(const QByteArray &xmpMetadata) +{ + Q_D(const QPdfWriter); + d->engine->setDocumentXmpMetadata(xmpMetadata); +} + +/*! + \since 5.15 + + Gets the document metadata, as it was provided with a call to setDocumentXmpMetadata. It will not + return the default metadata. + + \sa setDocumentXmpMetadata() +*/ + +QByteArray QPdfWriter::documentXmpMetadata() const +{ + Q_D(const QPdfWriter); + return d->engine->documentXmpMetadata(); +} + +/*! + \since 5.15 + + Adds \a fileName attachment to the PDF with (optional) \a mimeType + \a data contains the raw file data to embed into the PDF file. +*/ + +void QPdfWriter::addFileAttachment(const QString &fileName, const QByteArray &data, const QString &mimeType) +{ + Q_D(QPdfWriter); + d->engine->addFileAttachment(fileName, data, mimeType); +} + // Defined in QPagedPaintDevice but non-virtual, add QPdfWriter specific doc here #ifdef Q_QDOC /*! -- cgit v1.2.3