3

I want the title (a label) of my map in print composer to automatically contain the name I've given the print composer and also the date that it was created. For example I want it to say 'Really cool map of (print composer name) created on (date the print composer was created).'

I can then use it as a template for lots of other maps which will automatically update with the site name and date created.

I think I need to use the 'Insert an Expression' but I can't figure it out.

  • It might be possible to write a Python script that would create and auto-fill a custom variable in the print layout, @layout_creation_date, with the current date at the time of creating a new print layout. I couldn't find any similar examples, so you'd have to figure out a lot of new things. This Q&A might help a little bit: gis.stackexchange.com/questions/189075/… – csk Jul 15 at 14:35
2

Here you go:

This is a rad map of [% @layout_name %], created on [%format_date(now(),'dd.MM.yyyy')%]

Feel free to browse the field calculator's function-trees, since the help/examples offered are rather easy to understand.

  • It's not very exact, now() refers to the date when the layout is printed and not when the print composer was created. I don't found a such variable, only the project creation date ... Also, your answer is good but near. – J. Monticolo Jul 15 at 13:35
  • Hmm, project_creation_date doesn't print anything in my case. Haven't found any other option. – Erik Jul 15 at 13:43
2

You may use the HTML frame. Add a frame and add an expression like this

Really cool map of [% @layout_name %] printed on [% format_date(now(),'dd.MM.yyyy')%]

enter image description here

UPDATE (after Erik's comment):

Really cool map of [% @layout_name %] printed on [% format_date(@project_creation_date,'dd.MM.yyyy')%]

Gives in my case enter image description here

  • same comment as @Erik 's answer. – J. Monticolo Jul 15 at 13:37
  • I agree. Perhaps in this case, one should hard code the actual date of creating the map. (I can't see QGIS offering a 'created_date'-option.) – 9ls1 Jul 15 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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