I have a problem when I try to export a Map in the Layout of QGIS 3 with the Python API. Here is my code :
qpt = QDomDocument() qpt.setContent(content) layout = QgsLayout(QgsProject().instance()) layout.loadFromTemplate(qpt, QgsReadWriteContext()) mapItem = layout.referenceMap() layoutExporter = QgsLayoutExporter(layout) imageSettings = layoutExporter.ImageExportSettings() imageSettings.dpi = 150 imageSettings.generateWorldFile = 1 path = "path/to/my/iamge.tif" layoutExporter.exportToImage(path, settings=imageSettings)
When I export my layout's map I get an image with a white stripe at the bottom like in the following file :
The width of the stripe is variable when for example a widget (like the python console) is opened or not. It seams that the map of the layout doesn't fill its whole surface because its ratio is not the same as the map canvas' one.
Is there a way to say to the layout's map to fill completely ?