QPdfWriter 类

QPdfWriter 类是生成可用作描绘设备的 PDF 的类。 更多...

头: #include <QPdfWriter>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
继承: QObject and QPagedPaintDevice

公共类型

(从 6.8 起) 枚举类 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())
(从 6.8 起) QPdfWriter::ColorModel colorModel () const
QString creator () const
(从 6.8 起) QUuid documentId () const
QByteArray documentXmpMetadata () const
(从 6.8 起) QPdfOutputIntent outputIntent () const
QPagedPaintDevice::PdfVersion pdfVersion () const
int resolution () const
(从 6.8 起) void setColorModel (QPdfWriter::ColorModel model )
void setCreator (const QString & creator )
(从 6.8 起) void setDocumentId (QUuid documentId )
void setDocumentXmpMetadata (const QByteArray & xmpMetadata )
(从 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 从一系列绘制命令生成 PDF,使用 QPainter newPage () 方法可用于创建多个页面。

成员类型文档编制

[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 ).

常量 描述
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.

该枚举在 Qt 6.8 引入。

另请参阅 QColor and QGradient .

成员函数文档编制

[explicit] QPdfWriter:: QPdfWriter ( QIODevice * device )

构造 PDF 写入器,将 PDF 写入到 device .

[explicit] QPdfWriter:: QPdfWriter (const QString & filename )

构造 PDF 写入器,将 PDF 写入到 filename .

[virtual noexcept] QPdfWriter:: ~QPdfWriter ()

销毁 PDF 写入器。

void QPdfWriter:: addFileAttachment (const QString & fileName , const QByteArray & data , const QString & mimeType = QString())

添加 fileName 附件到 PDF 采用 (可选) mimeType . data 包含要嵌入到 PDF 文件中的原生文件数据。

[since 6.8] QPdfWriter::ColorModel QPdfWriter:: colorModel () const

Returns the color model used by this PDF writer. The default is QPdfWriter::ColorModel::Auto .

该函数在 Qt 6.8 引入。

另请参阅 setColorModel ().

QString QPdfWriter:: creator () const

返回文档创建者。

另请参阅 setCreator ().

[since 6.8] QUuid QPdfWriter:: documentId () const

Returns the ID of the document. By default, the ID is a randomly generated UUID.

该函数在 Qt 6.8 引入。

另请参阅 setDocumentId ().

QByteArray QPdfWriter:: documentXmpMetadata () const

获取文档元数据,因为它被提供当调用 setDocumentXmpMetadata 。它不会返回默认元数据。

另请参阅 setDocumentXmpMetadata ().

[override virtual] bool QPdfWriter:: newPage ()

重实现: QPagedPaintDevice::newPage ().

[since 6.8] QPdfOutputIntent QPdfWriter:: outputIntent () const

Returns the output intent used by this PDF writer.

该函数在 Qt 6.8 引入。

另请参阅 setOutputIntent ().

[override virtual protected] QPaintEngine *QPdfWriter:: paintEngine () const

重实现: QPaintDevice::paintEngine () const.

QPagedPaintDevice::PdfVersion QPdfWriter:: pdfVersion () const

返回此写入器的 PDF 版本。默认为 PdfVersion_1_4 .

另请参阅 setPdfVersion ().

int QPdfWriter:: resolution () const

返回 PDF 分辨率 (以 DPI 为单位)。

另请参阅 setResolution ().

[since 6.8] void QPdfWriter:: setColorModel ( QPdfWriter::ColorModel model )

Sets the color model used by this PDF writer to model .

该函数在 Qt 6.8 引入。

另请参阅 colorModel ().

void QPdfWriter:: setCreator (const QString & creator )

将文档创建者设为 creator .

另请参阅 creator ().

[since 6.8] void QPdfWriter:: setDocumentId ( QUuid documentId )

Sets the ID of the document to documentId .

该函数在 Qt 6.8 引入。

另请参阅 documentId ().

void QPdfWriter:: setDocumentXmpMetadata (const QByteArray & xmpMetadata )

设置文档元数据。此元数据不受影响通过 setTitle / setCreator 方法,因此,取决于用户是否要保持一致。 xmpMetadata 包含可嵌入 PDF 文件中的 XML 格式元数据。

另请参阅 documentXmpMetadata ().

[since 6.8] void QPdfWriter:: setOutputIntent (const QPdfOutputIntent & intent )

Sets the output intent used by this PDF writer to intent .

该函数在 Qt 6.8 引入。

另请参阅 outputIntent ().

void QPdfWriter:: setPdfVersion ( QPagedPaintDevice::PdfVersion version )

将此写入器的 PDF 版本设为 version .

version 与目前设置的值相同,则不会有任何改变。

另请参阅 pdfVersion ().

void QPdfWriter:: setResolution ( int resolution )

设置 PDF resolution 以 DPI 为单位。

此设置影响返回坐标系,例如 QPainter::viewport ().

另请参阅 resolution ().

void QPdfWriter:: setTitle (const QString & title )

将正在创建的文档的标题设为 title .

另请参阅 title ().

QString QPdfWriter:: title () const

返回文档标题。

另请参阅 setTitle ().