本文整理汇总了Python中safe_qgis.map.Map.printToPdf方法的典型用法代码示例。如果您正苦于以下问题:Python Map.printToPdf方法的具体用法?Python Map.printToPdf怎么用?Python Map.printToPdf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类safe_qgis.map.Map
的用法示例。
在下文中一共展示了Map.printToPdf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_printToPdf
# 需要导入模块: from safe_qgis.map import Map [as 别名]
# 或者: from safe_qgis.map.Map import printToPdf [as 别名]
def test_printToPdf(self):
"""Test making a pdf of the map - this is the most typical use of map.
"""
LOGGER.info('Testing printToPdf')
myLayer, _ = loadLayer('test_shakeimpact.shp')
myCanvasLayer = QgsMapCanvasLayer(myLayer)
CANVAS.setLayerSet([myCanvasLayer])
myRect = QgsRectangle(106.7894, -6.2308, 106.8004, -6.2264)
CANVAS.setExtent(myRect)
CANVAS.refresh()
myMap = Map(IFACE)
myMap.setImpactLayer(myLayer)
myMap.composeMap()
myPath = unique_filename(prefix='mapPdfTest',
suffix='.pdf',
dir=temp_dir('test'))
myMap.printToPdf(myPath)
LOGGER.debug(myPath)
myMessage = 'Rendered output does not exist: %s' % myPath
assert os.path.exists(myPath), myMessage
# pdf rendering is non deterministic so we can't do a hash check
# test_renderComposition renders just the image instead of pdf
# so we hash check there and here we just do a basic minimum file
# size check.
mySize = os.stat(myPath).st_size
myExpectedSize = 352798 # as rendered on linux ub 12.04 64
myMessage = 'Expected rendered map pdf to be at least %s, got %s' % (
myExpectedSize, mySize)
assert mySize >= myExpectedSize, myMessage