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?


1 Answer 1


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)

Not the answer you're looking for? Browse other questions tagged or ask your own question.