QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
Public Member Functions | List of all members
QgsPdfRenderer Class Reference

Utility class for rendering PDF documents. More...

#include <qgspdfrenderer.h>

Public Member Functions

 QgsPdfRenderer (const QgsPdfRenderer &other)=delete
 QgsPdfRenderer cannot be copied. More...
 
 QgsPdfRenderer (const QString &path)
 Constructs a PDF renderer for the file at the specified path. More...
 
 ~QgsPdfRenderer ()
 
QgsPdfRendereroperator= (const QgsPdfRenderer &other)=delete
 QgsPdfRenderer cannot be copied. More...
 
int pageCount () const
 Returns the number of pages in the PDF. More...
 
QRectF pageMediaBox (int pageNumber) const
 Returns the media box for the specified page. More...
 
QString path () const
 Returns the file path of the associated PDF file. More...
 
bool render (QPainter *painter, const QRectF &painterRect, int pageIndex)
 Renders the PDF from the specified path to a painter. More...
 

Detailed Description

Utility class for rendering PDF documents.

This functionality is not available on all platforms – it requires a build with the PDF4Qt library support enabled. On other platforms calling these methods will raise a QgsNotSupportedException.

Since
QGIS 3.36

Definition at line 46 of file qgspdfrenderer.h.

Constructor & Destructor Documentation

◆ QgsPdfRenderer() [1/2]

QgsPdfRenderer::QgsPdfRenderer ( const QString &  path)

Constructs a PDF renderer for the file at the specified path.

Definition at line 60 of file qgspdfrenderer.cpp.

◆ ~QgsPdfRenderer()

QgsPdfRenderer::~QgsPdfRenderer ( )
default

◆ QgsPdfRenderer() [2/2]

QgsPdfRenderer::QgsPdfRenderer ( const QgsPdfRenderer other)
delete

QgsPdfRenderer cannot be copied.

Member Function Documentation

◆ operator=()

QgsPdfRenderer & QgsPdfRenderer::operator= ( const QgsPdfRenderer other)
delete

QgsPdfRenderer cannot be copied.

◆ pageCount()

int QgsPdfRenderer::pageCount ( ) const

Returns the number of pages in the PDF.

Exceptions
QgsNotSupportedExceptionon QGIS builds without PDF4Qt library support.

Definition at line 77 of file qgspdfrenderer.cpp.

◆ pageMediaBox()

QRectF QgsPdfRenderer::pageMediaBox ( int  pageNumber) const

Returns the media box for the specified page.

Units are in PDF points.

Exceptions
QgsNotSupportedExceptionon QGIS builds without PDF4Qt library support.

Definition at line 93 of file qgspdfrenderer.cpp.

◆ path()

QString QgsPdfRenderer::path ( ) const
inline

Returns the file path of the associated PDF file.

Definition at line 64 of file qgspdfrenderer.h.

◆ render()

bool QgsPdfRenderer::render ( QPainter *  painter,
const QRectF &  painterRect,
int  pageIndex 
)

Renders the PDF from the specified path to a painter.

The painterRect argument specifies the target rectangle for the PDF page in painter coordinates.

Exceptions
QgsNotSupportedExceptionon QGIS builds without PDF4Qt library support.

Definition at line 106 of file qgspdfrenderer.cpp.


The documentation for this class was generated from the following files: