Skip to content

5.5. Print

Uroš Preložnik edited this page Jun 14, 2019 · 17 revisions

Setup

If you are using QGIS Server 2.18 please read this post QGIS Server 2.18 LTR Printing problem

If you are using Linux you can upgrade to QGIS Server 3.4 and don't have to deal with above fix for printing (also upgrade gisapp to 1.8.2 or higher)

To setup printing map to PDF in Web client with user data follow this:

  1. Set field print to true for project in database (to show print button)
  2. Create print composer(s) in QGIS project (to enable print button)
  3. 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.
  4. 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.

PDF result

Note: This works only for registered users, guest users do not get option to write own title or description!

Base layers

Web client contains map layer (=QGIS project) and optional base or overlay layers. GetPrint request is only send to QGIS server, so server must know base layer, if user wants to print it together with the map. Web client works much faster if calls are spread between QGIS project and other base layers (WMS, WMTS, OSM, Google,...).

Note: Use http protocol if possible. With QGIS 3 there are known issues with layers using https protocol.

So to achieve best performance and print currently selected base layer follow this:

  1. Add base layer as other layers into QGIS project and open Web client to see if the layer is in legend and available to use. Not all types are working, it is related to GDAL build with QGIS. For example on Ubuntu 2.14 with GDAL 1.11.3 it is possible to use WMS layers and OpenStreetMap (via QGIS OpenLayers plugin). With GDAL 2 also WMTS layers are working.
  2. If base layer is visible in Web Client, you can add it to database - Wiki documentation.
  3. Add its layer_id to table of projects as external base layer.
  4. Make sure that base 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.
  5. When user prints a map with base layer visible and if same layer name exist in QGIS project then this layer is added to layers list and it will be added to the PDF.
You can’t perform that action at this time.