While saving an atlas as PDF in QGIS, I can manually change the settings shown the image using "PDF Export Settings" window.
How can I set those options using PyQGIS?
Minimal code:
layout_manager = QgsProject.instance().layoutManager()
layout = layout_manager.layoutByName('LAYOUT_NAME')
layout_exporter = QgsLayoutExporter(layout)
layout_exporter.exportToPdf(path, QgsLayoutExporter.PdfExportSettings())
Best Answer
Setting those options using PyQGIS requires using
QgsLayoutExporter.PdfExportSettings()
instance.pdf_settings = QgsLayoutExporter.PdfExportSettings()
Then;
For "Always export as vector"
pdf_settings.forceVectorOutput = True
orFalse
.For "Export RDF metadata"
pdf_settings.exportMetadata = True
orFalse
."Text export" options:
For "Always Export Text as Paths"
pdf_settings.textRenderFormat = QgsRenderContext.TextFormatAlwaysOutlines
For "Always Export Text as Text Objects"
pdf_settings.textRenderFormat = QgsRenderContext.TextFormatAlwaysText
For "Disable tiled raster layer exports"
pdf_settings.rasterizeWholeImage = True
orFalse
.