QPdfWriter Class
The QPdfWriter class is a class to generate PDFs that can be used as a paint device. More...
Header: | #include <QPdfWriter> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
Inherits: | QObject and QPagedPaintDevice |
- List of all members, including inherited members
- QPdfWriter is part of Painting Classes.
Public Types
(since 6.8) enum class | ColorModel { RGB, Grayscale, CMYK, Auto } |
Public Functions
QPdfWriter(QIODevice *device) | |
QPdfWriter(const QString &filename) | |
virtual | ~QPdfWriter() |
void | addFileAttachment(const QString &fileName, const QByteArray &data, const QString &mimeType = QString()) |
(since 6.8) QPdfWriter::ColorModel | colorModel() const |
QString | creator() const |
(since 6.8) QUuid | documentId() const |
QByteArray | documentXmpMetadata() const |
(since 6.8) QPdfOutputIntent | outputIntent() const |
QPagedPaintDevice::PdfVersion | pdfVersion() const |
int | resolution() const |
(since 6.8) void | setColorModel(QPdfWriter::ColorModel model) |
void | setCreator(const QString &creator) |
(since 6.8) void | setDocumentId(QUuid documentId) |
void | setDocumentXmpMetadata(const QByteArray &xmpMetadata) |
(since 6.8) void | setOutputIntent(const QPdfOutputIntent &intent) |
void | setPdfVersion(QPagedPaintDevice::PdfVersion version) |
void | setResolution(int resolution) |
void | setTitle(const QString &title) |
QString | title() const |
Reimplemented Public Functions
virtual bool | newPage() override |
Reimplemented Protected Functions
virtual QPaintEngine * | paintEngine() const override |
Detailed Description
QPdfWriter generates PDF out of a series of drawing commands using QPainter. The newPage() method can be used to create several pages.
Member Type Documentation
[since 6.8]
enum class QPdfWriter::ColorModel
This enumeration describes the way in which the PDF engine interprets stroking and filling colors, set as a QPainter's pen or brush (via QPen and QBrush).
Constant | Value | Description |
---|---|---|
QPdfWriter::ColorModel::RGB | 0 | All colors are converted to RGB and saved as such in the PDF. |
QPdfWriter::ColorModel::Grayscale | 1 | All colors are converted to grayscale. For backwards compatibility, they are emitted in the PDF output as RGB colors, with identical quantities of red, green and blue. |
QPdfWriter::ColorModel::CMYK | 2 | All colors are converted to CMYK and saved as such. |
QPdfWriter::ColorModel::Auto | 3 | RGB colors are emitted as RGB; CMYK colors are emitted as CMYK. Colors of any other color spec are converted to RGB. This is the default since Qt 6.8. |
This enum was introduced in Qt 6.8.
Member Function Documentation
[explicit]
QPdfWriter::QPdfWriter(QIODevice *device)
Constructs a PDF writer that will write the pdf to device.
[explicit]
QPdfWriter::QPdfWriter(const QString &filename)
Constructs a PDF writer that will write the pdf to filename.
[virtual noexcept]
QPdfWriter::~QPdfWriter()
Destroys the pdf writer.
void QPdfWriter::addFileAttachment(const QString &fileName, const QByteArray &data, const QString &mimeType = QString())
Adds fileName attachment to the PDF with (optional) mimeType. data contains the raw file data to embed into the PDF file.
[since 6.8]
QPdfWriter::ColorModel QPdfWriter::colorModel() const
Returns the color model used by this PDF writer. The default is QPdfWriter::ColorModel::Auto.
This function was introduced in Qt 6.8.
See also setColorModel().
QString QPdfWriter::creator() const
Returns the creator of the document.
See also setCreator().
[since 6.8]
QUuid QPdfWriter::documentId() const
Returns the ID of the document. By default, the ID is a randomly generated UUID.
This function was introduced in Qt 6.8.
See also setDocumentId().
QByteArray QPdfWriter::documentXmpMetadata() const
Gets the document metadata, as it was provided with a call to setDocumentXmpMetadata. It will not return the default metadata.
See also setDocumentXmpMetadata().
[override virtual]
bool QPdfWriter::newPage()
Reimplements: QPagedPaintDevice::newPage().
[since 6.8]
QPdfOutputIntent QPdfWriter::outputIntent() const
Returns the output intent used by this PDF writer.
This function was introduced in Qt 6.8.
See also setOutputIntent().
[override virtual protected]
QPaintEngine *QPdfWriter::paintEngine() const
Reimplements: QPaintDevice::paintEngine() const.
QPagedPaintDevice::PdfVersion QPdfWriter::pdfVersion() const
Returns the PDF version for this writer. The default is PdfVersion_1_4
.
See also setPdfVersion().
int QPdfWriter::resolution() const
Returns the resolution of the PDF in DPI.
See also setResolution().
[since 6.8]
void QPdfWriter::setColorModel(QPdfWriter::ColorModel model)
Sets the color model used by this PDF writer to model.
This function was introduced in Qt 6.8.
See also colorModel().
void QPdfWriter::setCreator(const QString &creator)
Sets the creator of the document to creator.
See also creator().
[since 6.8]
void QPdfWriter::setDocumentId(QUuid documentId)
Sets the ID of the document to documentId.
This function was introduced in Qt 6.8.
See also documentId().
void QPdfWriter::setDocumentXmpMetadata(const QByteArray &xmpMetadata)
Sets the document metadata. This metadata is not influenced by the setTitle / setCreator methods, so is up to the user to keep it consistent. xmpMetadata contains XML formatted metadata to embed into the PDF file.
See also documentXmpMetadata().
[since 6.8]
void QPdfWriter::setOutputIntent(const QPdfOutputIntent &intent)
Sets the output intent used by this PDF writer to intent.
This function was introduced in Qt 6.8.
See also outputIntent().
void QPdfWriter::setPdfVersion(QPagedPaintDevice::PdfVersion version)
Sets the PDF version for this writer to version.
If version is the same value as currently set then no change will be made.
See also pdfVersion().
void QPdfWriter::setResolution(int resolution)
Sets the PDF resolution in DPI.
This setting affects the coordinate system as returned by, for example QPainter::viewport().
See also resolution().
void QPdfWriter::setTitle(const QString &title)
Sets the title of the document being created to title.
See also title().
QString QPdfWriter::title() const
Returns the title of the document.
See also setTitle().
© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.