Class: QgsPdfRenderer¶
- class qgis.core.QgsPdfRenderer¶
Bases:
sip.wrapper
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
.Added in version 3.36.
QgsPdfRenderer(path: str) Constructs a PDF renderer for the file at the specified
path
.Methods
Returns the number of pages in the PDF.
Returns the media box for the specified page.
Returns the file path of the associated PDF file.
Renders the PDF from the specified
path
to apainter
.- pageCount(self) int ¶
Returns the number of pages in the PDF.
- Raises:
QgsNotSupportedException – on QGIS builds without PDF4Qt library support.
- Return type:
int
- pageMediaBox(self, pageNumber: int) QRectF ¶
Returns the media box for the specified page. Units are in PDF points.
- Raises:
QgsNotSupportedException – on QGIS builds without PDF4Qt library support.
- Parameters:
pageNumber (int)
- Return type:
QRectF
- path(self) str ¶
Returns the file path of the associated PDF file.
- Return type:
str
- render(self, painter: QPainter, painterRect: QRectF, pageIndex: int) bool ¶
Renders the PDF from the specified
path
to apainter
.The
painterRect
argument specifies the target rectangle for the PDF page inpainter
coordinates.- Raises:
QgsNotSupportedException – on QGIS builds without PDF4Qt library support.
- Parameters:
painter (QPainter)
painterRect (QRectF)
pageIndex (int)
- Return type:
bool