gws.plugin.qgis.template
¶
QGIS Print template.
The Qgis print templates work this way:
We read the qgis project and locate a template object within by its title or the index, by default the first template is taken.
We find all label
and html
blocks in the template and create our html
templates from
them, so that they can make use of our placeholders like @legend
.
When rendering, we render our map as pdf.
Then we render these html templates, and create a clone of the qgis project with resulting html injected at the proper places.
Then we render the Qgis template without the map, using Qgis GetPrint
to generate html.
And finally, combine two pdfs so that the qgis pdf is above the map pdf. This is because we need qgis to draw grids and other decorations above the map.
Caveats/todos:
both qgis “paper” and the map element must be transparent
since we create a copy of the qgis project, it must use absolute paths to all assets
the position of the map in qgis is a couple of mm off when we combine, for better results, the map position/size in qgis must be integer
Source code: gws.plugin.qgis.template
Module Contents¶
- class gws.plugin.qgis.template.Config¶
Bases:
gws.base.template.Config
- cssPath: gws.FilePath | None¶
css file
- index: int | None¶
template index
- mapPosition: gws.UomSizeStr | None¶
position for the main map
- provider: Config.provider | None¶
qgis provider
- class gws.plugin.qgis.template.Object¶
Bases:
gws.base.template.Object
- cssPath: str¶
- htmlBlocks: dict[str, _HtmlBlock]¶
- mapPosition: gws.UomSize¶
- qgisTemplate: gws.plugin.qgis.caps.PrintTemplate¶
- serviceProvider: gws.plugin.qgis.provider.Object¶
- configure()¶
- configure_provider()¶
- render(tri)¶