1

Is it possible to use the QGIS API to change the orientation within page setup in the composer window.

We have a plugin that builds a map template based on user defined options. When they choose to print portrait maps page setup defaults to landscape.

I have trying adding this snippet of code to the plugin but that does not seem to do anything - perhaps it just changes the orientation of the map item?

    # Set orientation
    resText = self.ui.orientationComboBox.currentText()
    if resText.startswith('Portrait'):
        orient = 0
    else:
        #Landscape
        orient = 1
    composerView.composition().PaperOrientation(orient)
1

There's no direct way to set the paper orientation - you need to use QgsComposition::setPaperSize and set the page width and height as desired for your page orientation.

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.