CopperSpice API  1.7.2
QPdfWriter Class Reference

Generates a PDF which can be used as a paint device. More...

Inheritance diagram for QPdfWriter:
QObject QPagedPaintDevice QPaintDevice

Public Methods

 QPdfWriter (const QString &filename)
 
 QPdfWriter (QIODevice *device)
 
 ~QPdfWriter ()
 
QString creator () const
 
bool newPage () override
 
QPageLayout pageLayout () const override
 
int resolution () const
 
void setCreator (const QString &creator)
 
void setMargins (const QMarginsF &margins) override
 
bool setPageLayout (const QPageLayout &newPageLayout) override
 
bool setPageMargins (const QMarginsF &margins) override
 
bool setPageMargins (const QMarginsF &margins, QPageLayout::Unit units) override
 
bool setPageOrientation (QPageLayout::Orientation orientation) override
 
bool setPageSize (const QPageSize &size) override
 
void setPageSize (QPageSize::PageSizeId sizeId) override
 
void setPageSizeMM (const QSizeF &size) override
 
void setResolution (int resolution)
 
void setTitle (const QString &title)
 
QString title () const
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &objName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 
- Public Methods inherited from QPagedPaintDevice
 QPagedPaintDevice ()
 
 ~QPagedPaintDevice ()
 
QMarginsF margins () const
 
QPageSize::PageSizeId pageSize () const
 
QSizeF pageSizeMM () const
 
- Public Methods inherited from QPaintDevice
virtual ~QPaintDevice ()
 
int colorCount () const
 
int depth () const
 
int devicePixelRatio () const
 
qreal devicePixelRatioF () const
 
int height () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
bool paintingActive () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
int width () const
 
int widthMM () const
 

Protected Methods

int metric (PaintDeviceMetric id) const override
 
QPaintEnginepaintEngine () const override
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Protected Methods inherited from QPaintDevice
 QPaintDevice ()
 

Additional Inherited Members

- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 
- Public Slots inherited from QObject
void deleteLater ()
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 
- Properties inherited from QObject
 objectName
 

Detailed Description

The QPdfWriter class is used 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.

Constructor & Destructor Documentation

QPdfWriter::QPdfWriter ( const QString filename)
explicit

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

QPdfWriter::QPdfWriter ( QIODevice device)
explicit

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

QPdfWriter::~QPdfWriter ( )

Destroys the pdf writer.

Method Documentation

QString QPdfWriter::creator ( ) const

Returns the creator of the document.

See also
setCreator()
int QPdfWriter::metric ( PaintDeviceMetric  metric) const
overrideprotectedvirtual

Returns the metric information for the given paint device metric.

See also
PaintDeviceMetric

Reimplemented from QPaintDevice.

bool QPdfWriter::newPage ( )
overridevirtual

Starts a new page. Returns true on success.

Implements QPagedPaintDevice.

QPageLayout QPdfWriter::pageLayout ( ) const
overridevirtual

Returns the current page layout.

Use this method to access the current QPageSize, QMarginsF, QPageLayout::Orientation, QPageLayout::fullRect(), and QPageLayout::paintRect().

Since the return value is a copy of the current page layout, modifying properties will not affect the paint device. To change the print settings use methods like QPdfWriter::setPageMargins() or QPdfWriter::setPageLayout().

See also
setPageLayout(), setPageSize(), setPageOrientation(), setPageMargins()

Reimplemented from QPagedPaintDevice.

QPaintEngine * QPdfWriter::paintEngine ( ) const
overrideprotectedvirtual

Returns a pointer to the paint engine used for drawing on the device.

Implements QPaintDevice.

int QPdfWriter::resolution ( ) const

Returns the resolution of the PDF in DPI.

See also
setResolution()
void QPdfWriter::setCreator ( const QString creator)

Sets the creator of the document to creator.

See also
creator()
void QPdfWriter::setMargins ( const QMarginsF margins)
overridevirtual

Sets the page margins using margins. Margins are specified in millimeters. The margins are a hint to drawing methods and do not affect the coordinate system or clipping.

See also
margins()

Reimplemented from QPagedPaintDevice.

bool QPdfWriter::setPageLayout ( const QPageLayout newPageLayout)
overridevirtual

Sets the PDF page layout to newPageLayout. Returns true if the page layout was successfully set 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.

See also
pageLayout()

Reimplemented from QPagedPaintDevice.

bool QPdfWriter::setPageMargins ( const QMarginsF margins)
overridevirtual

Sets the PDF page margins in the current page layout units. Returns true if the page margins was successfully set to margins.

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 QPageLayout::margins().

See also
pageLayout()

Reimplemented from QPagedPaintDevice.

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

Sets the PDF page margins defined in the given units. Returns true if the page margins were successfully set to margins.

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 QPageLayout::margins().

See also
pageLayout()

Reimplemented from QPagedPaintDevice.

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

Sets the page orientation. Returns true if the page orientation was successfully set to 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 QPageLayout::pageOrientation().

See also
pageLayout()

Reimplemented from QPagedPaintDevice.

bool QPdfWriter::setPageSize ( const QPageSize size)
overridevirtual

Sets the PDF page size to size. Returns true if the page size was successfully set.

To get the current QPageSize use QPageLayout::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.

See also
pageLayout()

Reimplemented from QPagedPaintDevice.

void QPdfWriter::setPageSize ( QPageSize::PageSizeId  sizeId)
overridevirtual

Sets the PDF page size using the enum value sizeId.

Reimplemented from QPagedPaintDevice.

void QPdfWriter::setPageSizeMM ( const QSizeF size)
overridevirtual

Sets the page size to size. size is specified in millimeters. If the size matches a standard QPageSize::PageSizeId then the page size will be used, otherwise the enum value of QPageSize::Custom will be set.

See also
pageSizeMM()

Reimplemented from QPagedPaintDevice.

void QPdfWriter::setResolution ( int  resolution)

Sets the PDF resolution in DPI. This setting affects the coordinate system as returned by, for example QPainter::viewport().

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