1

The "GUI way" of exporting a map to a PDF in QGIS's layout manager is known to be Layout -> Export as PDF ....

I wonder if there is any way to do this the CLI way. Either from a python script or the shell. Does anybody know how one would achieve this, especially since QGIS 3.14 added CLI support?

loki
  • 514
  • 4
  • 18

1 Answers1

2

from script you can do it with the following code fragment:

manager = QgsProject.instance().layoutManager()
#layout = manager.layoutByName("Layout1")  # name of the layout 
layout = manager.layouts()[0]  # or first layout

exporter = QgsLayoutExporter(layout) exporter.exportToPdf("d:/layout.pdf", QgsLayoutExporter.PdfExportSettings())

eurojam
  • 10,762
  • 1
  • 13
  • 27