管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-11-07 0233f162e021c8b7ea765613dc15595a2cd9e9a4
QGIS/render.py
@@ -25,21 +25,28 @@
    template_content = f.read()
doc = QDomDocument()
doc.setContent(template_content)
layout.loadFromTemplate(doc, QgsReadWriteContext(), False)
layout.loadFromTemplate(doc, QgsReadWriteContext(), True)
# map = QgsLayoutItemMap(layout)
# map.zoomToExtent(layers[0].extent())
# # map.zoomToExtent(layers[0].extent())
# layout.addItem(map)
# collection = layout.pageCollection()
# page = QgsLayoutItemPage(layout)
# page.setPageSize('A4')
# collection.addPage(page)
collection = layout.pageCollection()
collection.deletePage(0)
page = QgsLayoutItemPage(layout)
page.setPageSize('A5', True)
collection.addPage(page)
collection.redraw()
# layoutView = QgsLayoutView()
# layoutView.setPreviewModeEnabled(True)
# layoutView.setContentsMargins(0, 0, 0, 0)
# layoutView.setCurrentLayout(layout)
# collection = layout.pageCollection()
# page = collection.page(0)
# # QgsUnitTypes.LayoutCentimeters
# size = QgsLayoutSize(2480, 1748, QgsUnitTypes.LayoutPixels)
# page.setPageSize('A3', True)
# imgSetting = QgsLayoutExporter.ImageExportSettings()
# imgSetting.imageSize.width = 4096
# imgSetting.imageSize.heigth = 3507
exporter = QgsLayoutExporter(layout)
img_path = os.path.join(r"E:/terrait/TianJin/LFServer/QGIS", "render.png")