-
Notifications
You must be signed in to change notification settings - Fork 0
Print Plugin
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.
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 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"
},
"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
- 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).
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>