Uncategorized

qgis – How to export all pages to pdf from Atlas using Python script


I have a QGIS project with multiple layouts maps and all are configured by atlas, I want to export to pdf all pages from atlas in a single pdf. My code export each page from each layout in a different pdf and after that I need to merge the pdfs for each layout, there some way solve this. I using QGIS 3.28

layouts_list = QgsProject.instance().layoutManager().printLayouts()

print("Encontrou", str(len(layouts_list)), "layouts")

for layout in layouts_list:
    my_atlas = layout.atlas()
    my_atlas.beginRender()
        
    while my_atlas.next():
        name = my_atlas.currentFilename()+ ' - FOLHA ' + str(my_atlas.currentFeatureNumber())
        print('Imprime', name)
        
        
        atlas_layout = my_atlas.layout()
        print("set atlas")
        exporter = QgsLayoutExporter(atlas_layout)
        print("set exporter")
        exporter.exportToPdf(destFolder + "https://gis.stackexchange.com/" + name + '.pdf', exporter.PdfExportSettings())



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *