MapStore Training

Table Of Contents

Previous topic

Using the BBOXQueryForm Plugin

Next topic

Get Feature Info Menu

This Page

Using the Print Plugin

This section illustrates how you can use the Print Plugin. The Print Plugin allows a user to create a nice and printer-friendly PDF of the current map and legend.

The MapStore Print Plugin needs some server side components deployed on GeoServer:

  1. The GeoServer Print Plugin based on MapFish Print
  2. YAML, a human friendly data serialization standard for all programming languages.

Printing a Map

  1. Open the MapComposer.
../../_images/printing1.png

MapComposer with Print Plugin.

Note

This Print configuration provides a World Countries layer overlay and several base layers which will be used to generate several kind of reports as examples.

  1. Search for the Print button on the Top ToolBar
../../_images/printing2.png

MapComposer Print button.

  1. Trying to click on the button with this default layout will send al alert
../../_images/printing3.png

MapComposer Print button error.

Warning

The Google base maps cannot be printed with this Print Plugin due to licensing issues.

  1. Select another non Google background from the Layers tree panel; as an instance the MapQuest OpenStreetMap one.
../../_images/printing4.png

MapQuest OpenStreetMap background selected.

  1. Click again on the Print button; a Print Preview dialog window should pop-up on the center of the map
../../_images/printing5.png

MapComposer Print Preview dialog window.

  1. As you may notice the dialog window shows several options. It is possible to change the Paper size, the DPI Resolution.

    Try few examples:

    • Change the Title of the map to MapStore Workshop and the Abstract to This is an example of Print Plugin report as depicted below

      ../../_images/printing6.png
    • Click on the Print button of the Preview Window dialog; you should be able to get a PDF similar to the one depicted below

      ../../_images/printing7.png
  2. As you can see in the previows example, the text of the legend is bigger than the available width. In order to avoid this, repeat the previows steps by enabling the Compact legend checkbox

../../_images/printing8.png

Compact Legend checkbox.

  1. Click on the Print button of the Preview Window dialog; you should be able to get a PDF similar to the one depicted below
../../_images/printing9.png

Compact Legend example.

Note

Notice how the legend width is now adapted to the column.

  1. If it is not enough, this example configuration allows also to print the legend on a new page.
../../_images/printing10.png

Legend on a separate page checkbox.

../../_images/printing11.png
../../_images/printing12.png

Legend on a separate page example.

Warning

The available layouts are not hardcoded on MapStore or fixed. They depend exclusively from the YAML config of the GeoServer Print Plugin, which is explained a bit deepter in the next section.

Customizing a Report

As stated before, the Print Plugin relies into a YAML configuration file.

YAML (rhymes with “camel”) is a human-friendly, cross language, Unicode based data serialization language designed around the common native data types of agile programming languages. It is broadly useful for programming needs ranging from configuration files to Internet messaging to object persistence to data auditing. Together with the Unicode standard for characters, this specification provides all the information necessary to understand YAML Version 1.2 and to create programs that process YAML information.

The Print Plugin configuration file is located into the folder

$TRAINING_ROOT/geoserver_data/printing/config.yaml

Note

Every time this file is modified, you have to refresh the MapStore browser page. MapStore reads the GeoServer Printing plugin configuration at startup, and therefore the internal MapStore Print module is initialized accordingly to the config.yaml.

Warning

You do not need to restart GeoServer nor any Tomcat instance, but just refresh the browser page.

References

Examples

  1. Update the DPIs and Scales
  • Open the $TRAINING_ROOT/geoserver_data/printing/config.yaml and try to update the DPIs and Scales
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#===========================================================================
# allowed DPIs
#===========================================================================
dpis:
  - 96
  - 150
  - 300

#===========================================================================
# the allowed scales
#===========================================================================
scales:
  - 500
  - 1000
  - 2000
  - 5000
  ...
  • Refresh the MapStore browser and see how the values have been updated on the Print Preview window too
  1. Change the print header
  • Open the $TRAINING_ROOT/geoserver_data/printing/config.yaml and try to update the A4 image maxWidth and url as follows:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#===========================================================================
A4 :
#===========================================================================
  mainPage:
    rotation: true
    pageSize: 842 595
    landscape: false
    items:
      - !columns
        absoluteX: 30
        absoluteY: 575
        width: 782
        items:
          - !image
            maxWidth: 450
            url: 'http://www.geo-solutions.it/static/img/geosolutions-logo.gif'
            ...
  • Refresh the MapStore browser and try to print an A4 report.
../../_images/printing13.png
  1. Experiment yourself
  • Open the $TRAINING_ROOT/geoserver_data/printing/config.yaml and try to play with the several formats elements and dimensions.
  • Refresh the MapStore browser and try to print the report in order to see how they change accordingly.