Azad Rasul
SmartRS

SmartRS

12- Map Printing

Azad Rasul's photo
Azad Rasul
·Jun 25, 2021·

1 min read

Subscribe to my newsletter and never miss my upcoming articles

Listen to this article

Layout.png

We use QgsLayoutExporter(), class, to export a layout that we opened

manager = QgsProject.instance().layoutManager()
print(manager.printLayouts())

layout = manager.layoutByName("Layout1")

we use QgsLayoutExporter() to export to image, SVG, and PDF

exporter = QgsLayoutExporter(layout)

Export to png image

exporter.exportToImage("D:/Python_QGIS/Layout1.png", QgsLayoutExporter.ImageExportSettings())

Layout1.png Export to pdf

exporter.exportToPdf("D:/Python_QGIS/Layout1.pdf", QgsLayoutExporter.PdfExportSettings())

Export to svg image

exporter.exportToSvg("D:/Python_QGIS/Layout1.svg", QgsLayoutExporter.SvgExportSettings())

Using for loop to export layout

for layout in manager.printLayouts():
    exporter = QgsLayoutExporter(layout)
    exporter.exportToImage("D:/Python_QGIS/Image2.png".format(layout.name()),
        QgsLayoutExporter.ImageExportSettings())

If you like the content, please SUBSCRIBE to my channel for the future content

 
Share this