-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
export layout output via terminal #26131
Comments
I learned the workaround for this. You can make a python script like this: #!/usr/bin/python3
import argparse
import os
from qgis.core import QgsApplication, QgsLayoutExporter, QgsProject
os.environ['QT_QPA_PLATFORM'] = 'offscreen'
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('project', help='project file path')
parser.add_argument('layout', help='name of layout to be printed')
parser.add_argument('output', help='name of the pdf output file')
args = parser.parse_args()
project_file = os.getcwd() + '/' + args.project
gui_flag = False
app = QgsApplication([], gui_flag)
app.initQgis()
project = QgsProject.instance()
project.setFileName(project_file)
project.read()
manager = QgsProject.instance().layoutManager()
layout = manager.layoutByName(args.layout)
exporter = QgsLayoutExporter(layout)
exporter.exportToPdf(args.output,
QgsLayoutExporter.PdfExportSettings())
app.exitQgis() Then you can now print your layout by running the script via terminal. |
Hi @gioman , can we close this feature request? |
@basilrabi yes, but it would be better give an explanation why. |
Creating a python script similar to this will be enough since the functionality needed is already exposed in the the python bindings. |
Author Name: Basil Eric Rabi (@basilrabi)
Original Redmine Issue: 18240
Redmine category:map_composer/printing
A terminal command like below, to print layouts by batches without opening the gui, would be nice.
qqis-layout -p project.qgs -l layoutName -o mymap.pdf
see https://gis.stackexchange.com/questions/167650/export-a-qgis-print-composer-file-qpt-as-pdf-from-the-command-line/167657#167657
The text was updated successfully, but these errors were encountered: