3

I noticed I can add multiple pages to a print composer - cool!

Can I use an expression to set the orientation of specific pages?

(I know a little python so if a function is more appropriate I'd be open to exploring that!)

I have about 5 pages, but need pages 2 and 4 to be landscape, whereas pages 1,3 and 5 should be portrait.

highlighting pages in qgis print composer to be rotated

There is a layout_numpages variable, but that's only for the number of pages, but in the Item properties tab, there is a layout_page variable under Composer item.

So I tried forcing the orientation with an expression like:

CASE
  WHEN  @layout_page IN (2,4)
    THEN 'landscape'
    ELSE 'portrait'
END

But that didn't have any effect. The other thing I can do is rotate all the map elements 90deg, but that's a little more work than just rotating the actual page to match the map elements.

2 Answers 2

2

As was answered before, changing page orientation is not enough. You also need to resize and move the map item.

Quoting from cited posts (this was for Atlas Feature but could be adapted)

For the item width -> (CASE WHEN bounds_width( $atlasgeometry ) >= bounds_height( $atlasgeometry) THEN 297 ELSE 210 END) - 30

For the item height -> (CASE WHEN bounds_width( $atlasgeometry ) >= bounds_height( $atlasgeometry) THEN 210 ELSE 297 END) - 10

I know answers providing links are not the best but it has been extensively described on two posts on the blog Gis Unchained.

Multiple format map series using QGIS 2.6 : Part 1 - Part 2

1
  • That's for using the atlas feature like you pointed out, but I'm not using that, just using the page option to insert some pages because my map elements are already sized and placed as needed, and there isn't a lot of them (4 pages of maps). I'll see if any of those articles are helpful, but the article seems a little overkill for what I'm trying to do.
    – SaultDon
    Commented Mar 24, 2016 at 15:17
1

Unfortunately, you cannot change page orientation for specific page numbers in the same layout. But you can choose different page orientation (landscape or Portrait) in composer manager, as you see below:

enter image description here

In your case, create a portrait layout and put pages 1,3,and 5 there, and create a landscape layout and put pages 2 and 4 there.

4
  • I considered this, but then the first map I have with overviews - I can't figure out how to automate the overviews showing up, seems like I can only place overviews when the maps exist in the same composer (can't reference maps from other composers). I'd like to avoid creating a separate map for the overview reference map with polygons showing the extent of the other maps.
    – SaultDon
    Commented Mar 24, 2016 at 15:16
  • I suspect this is due to a shortcoming in Qt 4.7, I seem to recall I might have fixed this in Qt 5 but don't quote me on that!
    – odysseus
    Commented Mar 24, 2016 at 17:23
  • @SaultDon In this case you cannot change the page orientation in the same composer to keep track of overview maps in page 1, and I am not sure if this is a shortcoming in Qt. But since there are other users asked the same question, for example here gis.stackexchange.com/questions/184946/…. It will be a great idea if this option of changing page orientation in the same composer can be suggested to QGIS developement team lists.osgeo.org/mailman/listinfo/qgis-developer
    – ahmadhanb
    Commented Mar 25, 2016 at 2:04
  • @ahmadhanb Opened a feature request, hub.qgis.org/issues/14566
    – SaultDon
    Commented Mar 25, 2016 at 14:25

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.