Class: QgsPdfRenderer¶
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.
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 a painter. |
- class qgis.core.QgsPdfRenderer[source]¶
Bases:
object- __init__(path: str | None)
Constructs a PDF renderer for the file at the specified
path.- Parameters:
path (Optional[str])
- pageCount(self) int[source]¶
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[source]¶
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
- render(self, painter: QPainter | None, painterRect: QRectF, pageIndex: int) bool[source]¶
Renders the PDF from the specified
pathto apainter.The
painterRectargument specifies the target rectangle for the PDF page inpaintercoordinates.- Raises:
QgsNotSupportedException – on QGIS builds without PDF4Qt library support.
- Parameters:
painter (Optional[QPainter])
painterRect (QRectF)
pageIndex (int)
- Return type:
bool