0

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 exports each page from each layout in a different PDF and after that I need to merge the PDFs for each layout. Is 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 + '/' + name + '.pdf', exporter.PdfExportSettings())

Vince
  • 20,017
  • 15
  • 45
  • 64
  • What happens if you create the exporter before the loop and only write it out after the loop rather than inside it? – Ian Turton Jan 05 '24 at 22:03
  • I think there is no need to loop over the altas pages, this makes the exporter for you. see for example: https://gis.stackexchange.com/a/328168/87346 – eurojam Jan 06 '24 at 06:43

0 Answers0