Hi,

Not sure it's available but you can use the following Python expression to
add the functionality

@qgsfunction(args='auto', group='Layout')
def get_page_format(layoutname, pagenumber, feature, parent, context):
    layout = QgsProject.instance().layoutManager().layoutByName(layoutname)
    page = layout.pageCollection().page(pagenumber - 1)
    return QgsApplication.pageSizeRegistry().find(page.pageSize())

and calling it with

get_page_format('demo', @layout_page)

Regards

Thomas Gratier

Le jeu. 20 mai 2021 à 23:46, Charles Dixon-Paver <char...@kartoza.com> a
écrit :

> Yeah I am not aware of a variable for this... But page sizes are actually
> more complicated than they seem. You can emulate it pretty easily with
> something like the following expression on a layout as you suggested:
>
> [%CASE
> WHEN @layout_pagewidth IS 297 AND @layout_pageheight IS 210 THEN 'On A4
> Landscape'
> WHEN @layout_pagewidth IS 210 AND @layout_pageheight IS 297 THEN 'On A4
> Portrait'
> WHEN @layout_pagewidth IS 420 AND @layout_pageheight IS 297 THEN 'On A3
> Landscape'
> WHEN @layout_pagewidth IS 297 AND @layout_pageheight IS 420 THEN 'On A3
> Portrait'
> ELSE 'With page dimensions of ' || @layout_pagewidth || ' x ' ||
> @layout_pageheight
> END%]
>
> On Thu, 20 May 2021 at 23:13, Tony Shepherd (FarmMaps NZ) <
> t...@farmmaps.nz> wrote:
>
>> Hi All
>>
>>
>>
>> Is there a variable that returns the page size of a print layout?
>>
>>
>>
>> I would like to add the page size to the scale below so it reads
>> something like “1:5,000 @ A3”
>>
>> I can see variables for width and height, but not Page Size?
>>
>>
>>
>> Or would I need to code in some ‘if’ &  ‘then’ statements using the width
>> variables to arrive at the page size?
>>
>>
>>
>>
>>
>>
>>
>> Cheers
>>
>> Tony
>>
>>
>>
>> *Tony Shepherd*  *|*  GeoSpatial / Mapping Manager
>>
>> Ph 027 435 6193  *|*  E t...@farmmaps.nz
>>
>> FarmMaps NZ, 3 Kerwood Place, Gore 9740
>>
>>
>>
>> [image: FM_logo1_small (Custom)]
>>
>>
>>
>>
>>
>> <http://tonyshepherd8.wixsite.com/home>
>> <https://www.wunderground.com/personal-weather-station/dashboard?ID=ISTLGORE2>
>>
>>
>> _______________________________________________
>> Qgis-user mailing list
>> Qgis-user@lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>
_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to