QPdfWriter Class

The QPdfWriter class is a class to generate PDFs that can be used as a paint device. More...

Header: #include <QPdfWriter>
qmake: QT += gui
Inherits: QObject and QPagedPaintDevice

Public Functions

QPdfWriter(const QString &filename)
QPdfWriter(QIODevice *device)
virtual ~QPdfWriter()
QString creator() const
QPageLayout pageLayout() const
QPagedPaintDevice::PdfVersion pdfVersion() const
int resolution() const
void setCreator(const QString &creator)
bool setPageLayout(const QPageLayout &pageLayout)
bool setPageMargins(const QMarginsF &margins)
bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units)
bool setPageOrientation(QPageLayout::Orientation orientation)
bool setPageSize(const QPageSize &pageSize)
void setPdfVersion(QPagedPaintDevice::PdfVersion version)
void setResolution(int resolution)
void setTitle(const QString &title)
QString title() const

Reimplemented Public Functions

virtual bool newPage() override
(obsolete) virtual void setMargins(const QPagedPaintDevice::Margins &m) override
(obsolete) virtual void setPageSize(QPagedPaintDevice::PageSize size) override
(obsolete) virtual void setPageSizeMM(const QSizeF &size) override

Reimplemented Protected Functions

virtual QPaintEngine *paintEngine() const override
  • 9 protected functions inherited from QObject
  • 1 protected function inherited from QPaintDevice

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 2 signals inherited from QObject
  • 1 public variable inherited from QObject
  • 10 static public members inherited from QObject
  • 9 protected functions inherited from QObject
  • 1 protected function inherited from QPaintDevice
  • 2 protected variables inherited from QObject

Detailed Description

The QPdfWriter class is a class to generate PDFs that can be used as a paint device.

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

QPdfWriter::QPdfWriter(const QString &filename)

Constructs a PDF writer that will write the pdf to filename.

QPdfWriter::QPdfWriter(QIODevice *device)

Constructs a PDF writer that will write the pdf to device.

[virtual] QPdfWriter::~QPdfWriter()

Destroys the pdf writer.

QString QPdfWriter::creator() const

Returns the creator of the document.

See also setCreator().

[override virtual] bool QPdfWriter::newPage()

Reimplemented from QPagedPaintDevice::newPage().

QPageLayout QPdfWriter::pageLayout() const

See also setPageLayout().

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

Reimplemented from QPaintDevice::paintEngine().

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 setPdfVersion().

int QPdfWriter::resolution() const

Returns the resolution of the PDF in DPI.

This function was introduced in Qt 5.3.

See also setResolution().

void QPdfWriter::setCreator(const QString &creator)

Sets the creator of the document to creator.

See also creator().

bool QPdfWriter::setPageLayout(const QPageLayout &pageLayout)

See also pageLayout().

bool QPdfWriter::setPageMargins(const QMarginsF &margins)

bool QPdfWriter::setPageMargins(const QMarginsF &margins, QPageLayout::Unit units)

bool QPdfWriter::setPageOrientation(QPageLayout::Orientation orientation)

bool QPdfWriter::setPageSize(const QPageSize &pageSize)

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

This function was introduced in Qt 5.3.

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