Print Plugin - geosolutions-it/MapStore GitHub Wiki
In order to enable the print plugin you need:
- GeoServer with print plugin installed
- config.yaml configuration file
The last version of the print plugin can be downloaded here
To install it on Geoserver you have to:
- Stop Geoserver
- Copy the plugin jars into the Geoserver WEB-INF/lib folder
- Restart Geoserver
When you have restarted, Geoserver will create a default configuration file in GEOSERVER_DATA_DIR/printing/config.yaml
Further info on how to customize the print plugin configuration files can be found on the MapFish print plugin page.
Geoserver Print services will be available at the following url:
http://name:port/geoserver/pdf
If the plugin is correctly configured, information on printing parameters are available at:
http://name:port/geoserver/pdf/info.json
NOTE: this are the info used by the MapStore print plugin.
To use the print plugin in MapStore you need a custom configuration. You can find one on the MapStore source repo here.
If you want to use mapfish-lib 2.0 or our modifications over this, you'll need the advanced file
This file can be customized with your own logo and/or formats.
The configuration file uses a banner, that should be reachable from the web, for example copying it in the www Geoserver folder.
The default configuration file and banner are available on the MapStore source repo in 'printing' sub directory here (directory structure respects final file locations on the Geoserver data directory folder).
All the javascript code and css stylesheets needed to use the plugin are already available in the default MapStore build, but they are non included in the page, so you need to uncomment the following existing lines in the application templates (see composer.html):
<link rel="stylesheet" type="text/css" href="externals/PrintPreview/resources/css/printpreview.css">
<script type="text/javascript" src="script/PrintPreview.js"></script>
You can find the templates in the following files:
- mapcomposer/WEB-INF/app/templates/composer.html (MapComposer template)
- mapcomposer/WEB-INF/app/templates/viewer.html (MapViewer template)
To enable the plugin you also need to change the MapStore configuration files:
- mapcomposer/WEB-INF/app/static/config/mapStoreConfig.js (for MapComposer)
- mapcomposer/WEB-INF/app/static/config/viewerConfig.js (for MapViewer)
editing the customTools property as follows:
"customTools":[
...
{
"ptype":"gxp_print",
"customParams":{
"outputFilename":"mapstore-print",
"geodetic": true
},
"ignoreLayers": "Google Hybrid,Bing Aerial,Google Terrain,Google Roadmap,Marker,GeoRefMarker",
"printService":"http://localhost:8080/geoserver/pdf/",
"legendPanelId":"legendPanel",
"actionTarget":{
"target":"paneltbar",
"index":4
}
}
]
A short description of the plugin properties:
- ptype: plugin name
- customParams: custom parameters for the print service request
- printParams: parameters for the WMS vendor options managements
- outputFileName: name of the file to download
- printService: url of the print service
- legendPanelId: identifier of the legend panel (if defined)
- actionTarget: (plugin parameters)
- target: id of the toolbar or panel where the print button should appear
- index: index of the button inside the panel / toolbar (order of the plugin relative to the other toolbar plugins).
- legendOnSeparatePage: (optional, default false) if true the "Legend on separate page" option is checked by default
- includeLegend: (optional, default true) if true the "Include legend" option is checked by default
- defaultResolutionIndex: (optional, default 0) index of the default selected option in the resolutions combo box
- defaultLayoutIndex: (optional, default 0) index of the default selected option in the layouts combo box
- ignoreLayers: (optional) a list of layers to be excluded from printing
- addLandscapeControl: (optional, default false) if true, we add landscape control in print preview
- appendLegendOptions: (optional, default false) if true, we add a new tab in print preview window to configure legend options for the print (icon size, font family...)
- addGraticuleControl: (optional, default false) if true, we add a new tab in print preview window to configure the graticule layer for the printing. Also, if you active it, bboxFit it's activated.
- bboxFit: (optional, default false) if true, the scale combo in the print preview it's removed and the map inside the plugin it's exact the same that the actual extent of the map.
There are some limitations to the use of the print plugin:
- To enable printing, WMS services and images used have to be accessible on the web without the need of authentication; in case you need to enable printing also with password protected wms services, look at the next section for a possibile solution
- Printing can work only loading layers directly from Geoserver, for example you can't use it with GeoWebCache published layers
Print plugin uses Wms GetMap requests to compose the map. So the servers under basic authentication protection must have an exception to allow the geoserver instance using the print plugin functionality to send requests. Example configuration for Apache2:
<Location /protected>
AuthType Basic
AuthName print-access
AuthUserFile /etc/apache2/passwd/protected
Require valid-user
Order allow,deny
Allow from 217.133.17.186 #proxy address
Satisfy any
</Location>