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 |
(since 6.8) enum class |
ColorModel { RGB, Grayscale, CMYK, Auto } |
| 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 |
| virtual bool | newPage() override |
| virtual QPaintEngine * | paintEngine() const override |
QPdfWriter generates PDF out of a series of drawing commands using QPainter. The newPage() method can be used to create several pages.
[since 6.8] enum class QPdfWriter::ColorModelThis 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.
[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.
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() constReturns 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().
Returns the creator of the document.
See also setCreator().
[since 6.8] QUuid QPdfWriter::documentId()
constReturns 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().
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() constReturns 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() constReimplements: QPaintDevice::paintEngine() const.
Returns the PDF version for this writer. The default is PdfVersion_1_4.
See also setPdfVersion().
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().
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().
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().
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().
Sets the PDF resolution in DPI.
This setting affects the coordinate system as returned by, for example QPainter::viewport().
See also resolution().
Sets the title of the document being created to title.
See also title().
Returns the title of the document.
See also setTitle().