[Qgis-user] Custom preset format page for print layouts

Thomas Gratier osgeo.mailinglist at gmail.com
Sun Jan 2 09:00:39 PST 2022


Hi,

In startup.py, add the following to register your custom Custom preset
format page for print layouts.


from qgis.core import QgsApplication, QgsPageSize, QgsLayoutSize,
QgsUnitTypes

pageSizeRegistry = QgsApplication.pageSizeRegistry()

# For demo purpose in PyQGIS, so commented
# print(len(pageSizeRegistry.entries()))
# print(pageSizeRegistry.entries()[0].size)
# print(pageSizeRegistry.entries()[0].displayName)
# print(pageSizeRegistry.entries()[0].name)

# You will see in the menu, myDisplayName with other default preset format
pages after executing the following line
pageSizeRegistry.add(QgsPageSize('myname', QgsLayoutSize(150, 100,
units=QgsUnitTypes.LayoutMillimeters), 'myDisplayName'))

# print(len(pageSizeRegistry.entries()))

Cheers

Thomas Gratier

Le mer. 29 déc. 2021 à 19:50, Christophe Besuchet <design at golok.net> a
écrit :

> Hello all,
>
> I'm often using the same custom page size in my print layouts, and I
> created several templates for this.
>
> However, if I have to add a new page, the later won't inherit my
> template's format settings; the Size menu will only propose standard
> presets and I will have to set the size manually (and the guides as well).
>
> Is there a way to create and save custom preset format pages so they will
> show up in the Size menu?
>
> In advance thank you for your help!
>
> Golok
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20220102/58a6966a/attachment.html>


More information about the Qgis-user mailing list