These dependencies must be installed manually in OSGeo4W Shell:
- docxtpl==0.16.7
- jinja2==2.11.2
- docx==0.2.4
- qrcode==7.4.2
pip install docxtpl jinja2 docx qrcode
- Rik Ferreira Alves
{{ variable }}
: An element from the dictionary namedvariable
will be used to fill this placeholder{% if <condition> %}
,{% else %}
,{% endif %}
: An if statement can be built inside the template using these tags{%- if <condition> -%}
,{%- else -%}
,{%- endif -%}
: An if statement, but escaping the ENTER or the SHIFT+ENTER from MS Word{% for <x> in <list> %}
,{% endfor %}
: A for statement can be built inside the template using these tags. Useful to iterate over child features
Each document has a complex dictionary with attributes extracted from the relational model centered in the reference layer. You can access all the attributes of the reference layer by calling the attribute name. Other dimenions are stores as dictionaries at the first level of the context dictionary, so:
- Context
global
project_obj
: AQgsProject
objectmapCanvas
: AQgsMapCanvas
objectproject_bbox
: A list of 4 elements: xmin, ymin, xmax, ymax referring to the boundary of the projectglobal_vars
: QGIS global variablesproject_vars
: QGIS project vairables
layer
layer_obj
:QgsVectorLayer
objectlayer_type
: The layer typelayer_geometry_type
: The layer geometry typelayer_name
: The layer namelayer_id
: The layer unique IDlayer_source
: The name of the sourcelayer_extent
: AQgsRectangle
object of the extent of the layerlayer_bbox
: A list of 4 elements: xmin, ymin, xmax, ymax referring to the boundary of the layer
feature
feature_obj
:QgsFeature
objectfeature_id
: Feature ID (equivalent of$id
in QGIS expression)feature_wkt
: Feature geometry as a well-known text stringfeature_geojson
: Feature geometry as GeoJSON stringfeature_extent
:QgsRectangle
of the feature extentfeature_centroid
:QgsPointXY
object of the feature centroid- All the attributes of the feature are called by their name, not their alias
related layer name
layer
feature
related layer name and so on...
layouts
layout name
layout_obj
:QgsPrintLayout
objectlayout_atlas
:QgsLayoutAtlas
object
{
"global": {
},
"layer": {
},
"feature": {
},
"IntLin": [
{
"layer": {...},
"feature": {...},
"IntLin__ATTACH": [
{...},
...
]
},
{},
{}
],
"IntPoli": [...],
"IntPto": [...],
"LocAre": [...],
"LocVer": [...],
"Nascente": [...],
"URUCUIA_PIALBE_V2__ATTACH": [...],
"layouts": {
"QgsMapaLocCad": {
"layout_obj": "<qgis._core.QgsPrintLayout object at 0x000001566C6EB4C0>",
"layout_atlas": "<qgis._core.QgsLayoutAtlas object at 0x000001566FE7B430>"
},
...
}
}
Filters are custom functions designed to extend the capabilities of the DOCX reports. Here is a list of the custom filters implemented by this plugin:
exportPrintLayout
: Expects alayout
dictionary, renders the map and returns a path pointing to the exported PNG figure. Parameters:layout_dict
: Alayout
dictionaryfeature_dict
: Afeature
dictionaryoutput_dir = None
: If specified, export the layout to a folder. If not, export the layout to a temporary directory
exportPictureFromBase64
: Expects a base64 string and returns the path of the exported imagebase64string
: A base64 stringfilename
: An output file nameoutput_dir
: If specified, export the picture to a folder. If not, export the picture to a temporary directory
renderPictureFromPath
: Expects a file path and returns anInlineImage
objectpath
: The path of the imagewidth
: If a number between 0 and 1 is specified, the width is a percentage of the page width available (without margins). If a number greater than 1 is specified, the width is a absolute valueheight = None
: If specified, forces a height value to the image. If not, preserves the aspect ratio of the image
xForMatch
:multipleCheckBoxes
:
- Although there is a Sphinx API documentation for PyQGIS, QGIS C++ API Reference is preferrable as it reveals the big picture of QGIS classes.