Table of Contents
Print module Client side
Please look at the examples in examples/print/.
The widgets you can use are:
Overrides
All the JS classes are accepting an overrides parameters. This parameter can be used to change the OL layers settings just for the print output. This can be usefull for several purpose:
- Go around a TileCache server and access the WMS server directly (baseURL and layers).
- Change the format of the requested map (format).
- Change the style (styles).
- Forcing or disabling a layer for printing (visibility).
- Choosing what layer can be used for printed overviews (overview). If one or more layers has overview set, only those will be shown in the overview (they still have to be visible, though).
Any value passed in the spec can be overridden like this.
It is a dictionary where the key are the layer's names and the values are dictionaries of parameters to change when printing.
For example:
var overrides = {
'rivers': {
format: 'image/svg+xml',
overview: true
},
'far': {
visibility: false
},
'sometimes': {
visibility: false,
300: {
visibility: true
}
}
}
In this case, the rivers layer will be printed vectorized (type 2 layer) and the far layer won't be printed. For the sometimes layer, we use the possibility to have an override that depends on the DPI chosen by the use for printing and this layer will be printed only when 300DPI is chosen.
Only the rivers layer will be shown in Map overviews.
Override legends
To use another text in legend (layer name or classe name), we can use the attribut "printText" in layer tree model:
...
text: '<img src="images/information.png"/> '
+ OpenLayers.i18n('Layer label'),
checked: false,
layerNames: ['myLayer'],
printText: OpenLayers.i18n('Print layer label'),
children : [
{text: 'Zone 1: 0.6 m/s<sup>2</sup>',
printText: 'Zone 1: 0.6 m/s2'
}
]
...
If printText is an empty string, the layer won't show up the the PDF legend.