3

I have to produce pdf maps everyday (corvid-19 stuff) for my organisation and want to create the file name based on the composer name preceeded by the current date. The name of the composer is the default but I have to type in the date in the form yyyyMMdd but this is a pain. So when I press "Export as pdf" button my file name will show "yyyyMMdd-LAyout name.pdf". I've tried project variables, custom functions etc. but can't get anything to work!

Anyone, any ideas? I'm using 3.12.1-Bucuresti on Windows 10.

3
  • 1
    Show us what you tried and where you tried it and what the result was. Apr 17, 2020 at 10:26
  • I think I should clarify: it is not the things I've tried to do i.e create a project variable etc. but finding a way of using that information to populate the output file name with any custom data other than the layout name. It may be that I have to do this by updating the layout name but I don't know how to do this either - this is what I used for the project variable value: format_date(now(),'yyyyMMdd')||'-VP-'||@layout_name||'reduced'
    – RBCMark
    Apr 17, 2020 at 11:24
  • @RBCMark this is the kind of thing I have wanted to do with Python, ie. point to a QGIS project and export a layout with the current data and control the output name in the script... I haven't (yet) had the need to figure it out, but would like to implement it in the future... Apr 17, 2020 at 17:16

1 Answer 1

5

You can rename layouts by going to Layout > Rename Layout in the layout window.

But as a workaround to automate adding the date/time to your map filename... Try using a single feature as an atlas to take advantage of the ability to use expressions for atlas file names.

  1. Add to your project a layer with a single feature. It can be any geometry, anywhere, with no attributes - just a dummy layer.

enter image description here

  1. In your Layout window, go to Atlas > Settings and generate an atlas using that layer. Also ensure that it is a hidden coverage layer, and under Output > Output filename expression, uncheck 'Single file export where possible', and click the little epsilon button to enter your expression as desired.

enter image description here

  1. Click on your map item(s) and ensure that 'Controlled by atlas' for your map item is unchecked to make sure your map won't actually try to centre on the atlas feature location.

enter image description here

  1. Finally, ensure you've enabled your atlas by clicking the atlas map button at the top. Now when you export as PDF from Layout > Save as PDF it will have the expression as a filename. Notice the layout name here is 'layout' but the filename is derived from the expression in step 2.

enter image description here

1
  • she_weeds - perfect. Thank you.
    – RBCMark
    Apr 17, 2020 at 12:45

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.