QPdfWriter Class▲
-
Header: QPdfWriter
-
qmake: QT += gui
-
Inherits: QObject and QPagedPaintDevice
-
Group: QPdfWriter is part of Painting Classes
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 Function Documentation▲
[explicit] QPdfWriter::QPdfWriter(const QString &filename)▲
Constructs a PDF writer that will write the pdf to filename.
[explicit] QPdfWriter::QPdfWriter(QIODevice *device)▲
Constructs a PDF writer that will write the pdf to device.
[virtual] QPdfWriter::~QPdfWriter()▲
Destroys the pdf writer.
[since 5.15] 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.
This function was introduced in Qt 5.15.
QString QPdfWriter::creator() const▲
[since 5.15] QByteArray QPdfWriter::documentXmpMetadata() const▲
Gets the document metadata, as it was provided with a call to setDocumentXmpMetadata. It will not return the default metadata.
This function was introduced in Qt 5.15.
See Also▲
See also setDocumentXmpMetadata()
[override virtual] bool QPdfWriter::newPage()▲
Reimplements: QPagedPaintDevice::newPage().
[since 5.3] QPageLayout QPdfWriter::pageLayout() const▲
Returns the current page layout. Use this method to access the current QPageSize, QPageLayout::Orientation, QMarginsF, fullRect() and paintRect().
Note that you cannot use the setters on the returned object, you must either call the individual QPdfWriter methods or use setPageLayout().
This function was introduced in Qt 5.3.
See Also▲
See also setPageLayout(), setPageSize(), setPageOrientation(), setPageMargins()
[override virtual protected] QPaintEngine *QPdfWriter::paintEngine() const▲
Reimplements: QPaintDevice::paintEngine() const.
[since 5.10] QPagedPaintDevice::PdfVersion QPdfWriter::pdfVersion() const▲
Returns the PDF version for this writer. The default is PdfVersion_1_4.
This function was introduced in Qt 5.10.
See Also▲
See also setPdfVersion()
[since 5.3] int QPdfWriter::resolution() const▲
Returns the resolution of the PDF in DPI.
This function was introduced in Qt 5.3.
See Also▲
See also setResolution()
void QPdfWriter::setCreator(const QString &creator)▲
[since 5.15] 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.
This function was introduced in Qt 5.15.
See Also▲
See also documentXmpMetadata()
[since 5.3] bool QPdfWriter::setPageLayout(const QPageLayout &newPageLayout)▲
Sets the PDF page layout to newPageLayout.
You should call this before calling QPainter::begin(), or immediately before calling newPage() to apply the new page layout to a new page. You should not call any painting methods between a call to setPageLayout() and newPage() as the wrong paint metrics may be used.
Returns true if the page layout was successfully set to newPageLayout.
This function was introduced in Qt 5.3.
See Also▲
See also pageLayout()
[since 5.3] bool QPdfWriter::setPageMargins(const QMarginsF &margins)▲
Set the PDF page margins in the current page layout units.
You should call this before calling QPainter::begin(), or immediately before calling newPage() to apply the new margins to a new page. You should not call any painting methods between a call to setPageMargins() and newPage() as the wrong paint metrics may be used.
To get the current page margins use pageLayout().pageMargins().
Returns true if the page margins were successfully set to margins.
This function was introduced in Qt 5.3.
See Also▲
See also pageLayout()
[since 5.3] bool QPdfWriter::setPageMargins(const QMarginsF &margins, QPageLayout::Unit units)▲
Set the PDF page margins defined in the given units.
You should call this before calling QPainter::begin(), or immediately before calling newPage() to apply the new margins to a new page. You should not call any painting methods between a call to setPageMargins() and newPage() as the wrong paint metrics may be used.
To get the current page margins use pageLayout().pageMargins().
Returns true if the page margins were successfully set to margins.
This function was introduced in Qt 5.3.
See Also▲
See also pageLayout()
[since 5.3] bool QPdfWriter::setPageOrientation(QPageLayout::Orientation orientation)▲
Sets the PDF page orientation.
The page orientation is used to define the orientation of the page size when obtaining the page rect.
You should call this before calling QPainter::begin(), or immediately before calling newPage() to apply the new orientation to a new page. You should not call any painting methods between a call to setPageOrientation() and newPage() as the wrong paint metrics may be used.
To get the current QPageLayout::Orientation use pageLayout().pageOrientation().
Returns true if the page orientation was successfully set to orientation.
This function was introduced in Qt 5.3.
See Also▲
See also pageLayout()
[since 5.3] bool QPdfWriter::setPageSize(const QPageSize &pageSize)▲
Sets the PDF page size to pageSize.
To get the current QPageSize use pageLayout().pageSize().
You should call this before calling QPainter::begin(), or immediately before calling newPage() to apply the new page size to a new page. You should not call any painting methods between a call to setPageSize() and newPage() as the wrong paint metrics may be used.
Returns true if the page size was successfully set to pageSize.
This function was introduced in Qt 5.3.
See Also▲
See also pageLayout()
[since 5.10] 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.
This function was introduced in Qt 5.10.
See Also▲
See also pdfVersion()
[since 5.3] void QPdfWriter::setResolution(int resolution)▲
Sets the PDF resolution in DPI.
This setting affects the coordinate system as returned by, for example QPainter::viewport().
This function was introduced in Qt 5.3.
See Also▲
See also resolution()