I have a trouble exporting a print layout in QGIS 3.10 to PDF when doing it programmatically. I've created a project with print layout manually and now just want to modify the content of the map with python and then save it as PDF. This is the code I tried for export, everything works just fine except the last line, which does nothing and ends with code 4.
manager = QgsProject.instance().layoutManager()
layout = manager.layoutByName("my_layout")
exporter = QgsLayoutExporter(layout)
filename = "C://layout.pdf"
#so far so good, but this doesnt create the file:
exporter.exportToPdf(filename, QgsLayoutExporter.PdfExportSettings())
Any idea what could be wrong? When I run the export of the same layout manually, it works fine.