<div dir="ltr"><div>Hi,</div><div><br></div><div>Hope the following will be more understandable from a non-coder<br></div><div><br></div><div># Below tell you how many entries (QgsPageSize) are already present (A4, A3, ...) before<br></div><div>print(len(pageSizeRegistry.entries()))</div><div># To inspect content of first entry (was useful to understand was is present in each QgsPageSize)<br></div><div>print(pageSizeRegistry.entries()[0].size)</div>print(pageSizeRegistry.entries()[0].displayName)<br><div>print(pageSizeRegistry.entries()[0].name)</div><div><br></div><div>You could run also run the following to see all infos for all preset formats<br></div><div><br></div><div>for entry in pageSizeRegistry.entries():<br>    print("Size: ", entry.size)</div><div>    print(f"EncodedSize: {entry.size.encodeSize()}")</div><div>    print(f"DisplayName: {entry.displayName}")<br>    print(f"Name: {<a href="http://entry.name">entry.name</a>}")</div><div><br></div><div>Testing after adding the part `pageSizeRegistry.add(...` show you have now one more entry compare to before<br></div><div>print(len(pageSizeRegistry.entries()))</div><div><br></div><div>Regards</div><div><br></div><div>Thomas<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le dim. 2 janv. 2022 à 21:16, Christophe Besuchet <<a href="mailto:design@golok.net">design@golok.net</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div>Hi Thomas,</div><div><br></div><div>Thanks a bunch for your answer and your code. It works like a charm!</div><div><br></div><div>However, I'm really bad at coding and I'm not sure why some lines are commented; since your code works without uncommenting these lines, can you tell me what's their purpose?</div><div><br></div><div>Cheers,</div><div><br></div><div>Golok</div><div><br><blockquote type="cite"><div>On 2 Jan 2022, at 18:00, Thomas Gratier <<a href="mailto:osgeo.mailinglist@gmail.com" target="_blank">osgeo.mailinglist@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><div>Hi,<br></div><div><br></div><div>In startup.py, add the following to register your custom Custom preset format page for print layouts.</div><div><br></div><div><br></div>from qgis.core import QgsApplication, QgsPageSize, QgsLayoutSize, QgsUnitTypes<br><br>pageSizeRegistry = QgsApplication.pageSizeRegistry()<br><br># For demo purpose in PyQGIS, so commented<br># print(len(pageSizeRegistry.entries()))<br># print(pageSizeRegistry.entries()[0].size)<br># print(pageSizeRegistry.entries()[0].displayName)<br># print(pageSizeRegistry.entries()[0].name)<br><br># You will see in the menu, myDisplayName with other default preset format pages after executing the following line<br>pageSizeRegistry.add(QgsPageSize('myname', QgsLayoutSize(150, 100, units=QgsUnitTypes.LayoutMillimeters), 'myDisplayName'))<br><br><div># print(len(pageSizeRegistry.entries()))</div><div><br></div><div>Cheers</div><div><br></div><div>Thomas Gratier<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mer. 29 déc. 2021 à 19:50, Christophe Besuchet <<a href="mailto:design@golok.net" target="_blank">design@golok.net</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello all,<br>
<br>
I'm often using the same custom page size in my print layouts, and I created several templates for this.<br>
<br>
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).<br>
<br>
Is there a way to create and save custom preset format pages so they will show up in the Size menu?<br>
<br>
In advance thank you for your help!<br>
<br>
Golok<br>
_______________________________________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
</blockquote></div>
</div></blockquote></div><br></div></blockquote></div>