I want to include the print size of my layout (e.g. "A3") as part of a label on the map, how can I write an expression to capture this information automatically?

I am using QGIS 3.12.

  • 2
    I am a bit confused. Usually you'd either have a template for the usual sheet sizes, or you'd build the layout from scratch, where you'd have to enter the sheet size anyway - so why use an expression? Could you explain your workflow a bit more detailed?
    – Erik
    Apr 21, 2020 at 7:51
  • Yes I am intending to use my layout to create templates, these will then be used to generate pdf maps and I want these to have a label such as "1:5000 when printed at A3". Because I will produce the pdf at A3 size but cannot control how users might print the pdf eg they may print it onto an A4 page then just to have scale 1:5000 would be incorrect. Hope this explains!
    – Jools
    Apr 22, 2020 at 7:52
  • 2
    This is why you include a scalebar.
    – Erik
    Apr 22, 2020 at 8:09

1 Answer 1


When in print layout you can add a new Label to the layout and in the item properties click on insert an expression. You could then try something like this to display the page height and then width separated by a comma:

[% @layout_pageheight ||', '|| @layout_pagewidth %]

Note: You can also add a numeric scale by first clicking on the scale icon in the map layout screen,

enter image description here

any changing the style to numeric. This will be dynamic and will change when map scale is changed or map dimensions , and will be in the form you mention above (e.g. 1:5000).

enter image description here

If you want to display page size (e.g. A4)

You will need to write a custom expression similar to this below

   WHEN  @layout_pagewidth  = 297 AND  @layout_pageheight = 210 THEN 'A4' 
   WHEN  @layout_pagewidth  = xx AND  @layout_pageheight = xx THEN 'A3' 
   ELSE 'Custom'                                                         
  • 3
    wow, how did you make that video?
    – Hans Erren
    Apr 21, 2020 at 11:14
  • 4
    @HansErren created a GIF with ScreenToGif and uploaded it when writing my answer
    – AWGIS
    Apr 21, 2020 at 11:38
  • Thanks - is there a way to show the size eg A3 rather than the dimensions?
    – Jools
    Apr 22, 2020 at 8:11
  • The only way I believe that is possible is to write a custom expression where if certain dimension criteria are met you output the page size (e.g. A3, A4 or Custom where the criteria is not met)
    – AWGIS
    Apr 22, 2020 at 8:15
  • See example in edited answer above
    – AWGIS
    Apr 22, 2020 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.