-
Notifications
You must be signed in to change notification settings - Fork 31
5.5. Print
Use QGIS Server 3.4! There are printing issues with new LTR QGIS 3.10!
To setup printing map to PDF in Web client with user data follow this:
- Set field
print
to true for project in database (to show print button) - Create print composer(s) in QGIS project (to enable print button)
- Make PostgreSQL connection to gisapp database in QGIS and add
users_print_view
to Layers panel. It will not show in Web client, just needs to be in layers panel. - Add attribute table to print composer(s) and adjust it to show table
users_print_view
. Because of the filter parameter upon printing this table will always hold only one record. Adjust attributes to show labels you want from user printing the map.
Available fields are:
FROM DATABASE FOR USER PRINTING THE MAP:
- user_name
- user_email
- display_name
- user_id
USER OWN DESCRIPTION AND TITLE ENTERED IN WEB CLIENT:
- title
- description
You can customize this and add table many times, for example on top for displaying title and larger font and somewhere else displaying description and user info with smaller font.
Note: This works only for registered users, guest users do not get option to write own title or description!
To use external layers from web client in printing you have following options depending on the layer type:
WMS layer will be dynamically added to printed page. QGIS Server must be 3.4 for this to work. Link to documentation for external wms layers - https://docs.qgis.org/3.4/en/docs/user_manual/working_with_ogc/server/services.html#external-wms-layers
Add WMS print definition below to existing WMTS layer definition that will be used for printing. If your layer does not have option to request WMS source, you can add WMTS layer to QGIS and use that QGIS project for WMS print definition.
...
"print": {
"url": "wms_layer_url",
"layers": "wms_layer_name",
"styles": "",
"format": "image/png"
}
Note: Use http protocol if possible. With QGIS 3 there are known issues with layers using https protocol.
- Add layer into QGIS project and open Web client to see if the layer is in legend and available to use.
- If layer is visible in Web Client, you can add it to database - Wiki documentation and refer its id in project.
- Make sure that layer in database (field
display_name
) has same name also inside QGIS project. If this is the case then layer from QGIS project is hidden from legend tree in Web client and it will be only used for possible printing. - When user prints a map with base layer visible and if same layer name exist in QGIS project then this layer is added to to the PDF.