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 引入。
[explicit]
QPdfWriter::
QPdfWriter
(
QIODevice
*
device
)
構造 PDF 寫入器,將 PDF 寫入到 device .
[explicit]
QPdfWriter::
QPdfWriter
(const
QString
&
filename
)
構造 PDF 寫入器,將 PDF 寫入到 filename .
[virtual noexcept]
QPdfWriter::
~QPdfWriter
()
銷毀 PDF 寫入器。
添加 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 ().
返迴文檔創建者。
另請參閱 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 ().
獲取文檔元數據,因為它被提供當調用 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.
返迴此寫入器的 PDF 版本。默認為
PdfVersion_1_4
.
另請參閱 setPdfVersion ().
返迴 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 ().
將文檔創建者設為 creator .
另請參閱 creator ().
[since 6.8]
void
QPdfWriter::
setDocumentId
(
QUuid
documentId
)
Sets the ID of the document to documentId .
該函數在 Qt 6.8 引入。
另請參閱 documentId ().
設置文檔元數據。此元數據不受影響通過 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 ().
將此寫入器的 PDF 版本設為 version .
若 version 與目前設置的值相同,則不會有任何改變。
另請參閱 pdfVersion ().
設置 PDF resolution 以 DPI 為單位。
此設置影響返迴坐標係,例如 QPainter::viewport ().
另請參閱 resolution ().
將正在創建的文檔的標題設為 title .
另請參閱 title ().
返迴文檔標題。
另請參閱 setTitle ().