| | |
| | | node.setItemVisibilityChecked(flag) |
| | | |
| | | |
| | | QgsApplication.setPrefixPath(r"C:/Program Files/QGIS 3.16/bin", True) |
| | | # QgsApplication.setPrefixPath(r"E:/terrait/TianJin/LFServer/QGIS/", True) |
| | | qgs = QgsApplication([], True) |
| | | qgs.initQgis() |
| | | |
| | | project = QgsProject.instance() |
| | | project.read(r'E:/terrait/TianJin/LFServer/QGIS/Test.qgz') |
| | | project.read(r'Test.qgz') |
| | | print("FileName: " + project.fileName()) |
| | | |
| | | # layout = QgsPrintLayout(project) |
| | | layout = QgsLayout(project) |
| | | # layout.initializeDefaults() |
| | | |
| | | with open(r"E:/terrait/TianJin/LFServer/QGIS/Template.qpt", 'r', encoding='utf-8') as f: |
| | | with open(r"Template.qpt", 'r', encoding='utf-8') as f: |
| | | template_content = f.read() |
| | | doc = QDomDocument() |
| | | doc.setContent(template_content) |
| | |
| | | |
| | | # "阀室", "站场", "管道中心线", "矢量注记", "矢量图", "高德影像注记", "高德影像", "影像注记", "影像图" |
| | | # showLayers = ["阀室", "管道中心线", "矢量注记", "矢量图"] |
| | | showLayers = map.id().split(',') |
| | | showLayers = layout.customProperty("layers").split(',') |
| | | root = project.layerTreeRoot() |
| | | # setLayersValid(project, showLayers) |
| | | setItemVisibility(root, showLayers) |
| | |
| | | map.refresh() |
| | | |
| | | exporter = QgsLayoutExporter(layout) |
| | | img_path = os.path.join(r"E:/terrait/TianJin/LFServer/QGIS", "render.png") |
| | | # img_path = os.path.join(r"E:/terrait/TianJin/LFServer/QGIS", "render.png") |
| | | img_path = layout.customProperty("imgPath") |
| | | exporter.exportToImage(img_path, QgsLayoutExporter.ImageExportSettings()) |
| | | |
| | | qgs.exitQgis() |