Class: QgsLayoutItemPage

Item representing the paper in a layout.

Class Hierarchy

Inheritance diagram of qgis.core.QgsLayoutItemPage

Base classes

QgsLayoutItem

Base class for graphical items within a QgsLayout.

QgsLayoutObject

A base class for objects which belong to a layout.

QObject

QgsExpressionContextGenerator

Abstract interface for generating an expression context.

QGraphicsRectItem

QAbstractGraphicsShapeItem

QGraphicsItem

QgsLayoutUndoObjectInterface

Interface for layout objects which support undo/redo commands.

class qgis.core.QgsLayoutItemPage[source]

Bases: QgsLayoutItem

__init__(layout: QgsLayout | None)

Constructor for QgsLayoutItemPage, with the specified parent layout.

Parameters:

layout (Optional[QgsLayout])

Landscape = 1
class Orientation

Bases: int

Portrait = 0
UndoPageSymbol = 3000
static create(layout: QgsLayout | None) QgsLayoutItemPage | None[source]

Returns a new page item for the specified layout.

The caller takes responsibility for deleting the returned object.

Parameters:

layout (Optional[QgsLayout])

Return type:

Optional[QgsLayoutItemPage]

static decodePageOrientation(string: str | None)[source]

Decodes a string representing a page orientation. If specified, ok will be set to True if string could be successfully interpreted as a page orientation.

Parameters:

string (Optional[str]) -> (QgsLayoutItemPage.Orientation)

orientation(self) QgsLayoutItemPage.Orientation[source]

Returns the page orientation.

Note

There is no direct setter for page orientation - use setPageSize() instead.

Return type:

QgsLayoutItemPage.Orientation

pageLayout(self) QPageLayout[source]

Returns the page layout for the page, suitable to pass to QPrinter.setPageLayout

Added in version 3.20.

Return type:

QPageLayout

pageSize(self) QgsLayoutSize[source]

Returns the size of the page.

See also

setPageSize()

Return type:

QgsLayoutSize

pageStyleSymbol(self) QgsFillSymbol | None[source]

Returns the symbol to use for drawing the page background.

Added in version 3.10.

Return type:

Optional[QgsFillSymbol]

setPageSize(self, size: QgsLayoutSize)[source]

Sets the size of the page.

See also

pageSize()

setPageSize(self, size: Optional[str], orientation: QgsLayoutItemPage.Orientation = QgsLayoutItemPage.Portrait) -> bool Sets the page size to a known page size, e.g. “A4” and orientation. The known page sizes are managed by QgsPageSizeRegistry. Valid page sizes can be retrieved via QgsPageSizeRegistry.entries(). The function returns True if size was a valid page size and the page size was changed. If False is returned then size could not be matched to a known page size.

See also

pageSize()

Parameters:

size (QgsLayoutSize)

setPageStyleSymbol(self, symbol: QgsFillSymbol | None)[source]

Sets the symbol to use for drawing the page background.

Ownership of symbol is transferred to the page.

Added in version 3.10.

Parameters:

symbol (Optional[QgsFillSymbol])