[OpenLayers-Users] Print to PDF via GeoServer - Example?

Benoit PESTY tchule at hotmail.com
Mon Jun 18 05:18:12 EDT 2007


Hello,

I'm needing this functionnality too (except I plan to use Mapserver and 
BIRT).

Extending on Christopher's code I've done the function below.

My problem now is that I'd like to render the vector layers too but I don't 
really know how to do that.


Tchule.

------------------------------------------------------------------

function getURLforPrinting() {

		// Get Layer List
		var layersstring = [];
		for (var i=0; i < map.layers.length; i++) {

			var layer = this.map.layers[i];

			if (layer.isVector) {

				// TODO : Vector Layer

			} else {

				if (layer.isBaseLayer && layer == this.map.baseLayer) {
					// Base Layer
            		layersstring.push(map.layers[i].params.LAYERS);
	            } else if (layer.getVisibility()) {
	            	// Overlay
	            	layersstring.push(map.layers[i].params.LAYERS);
	            }
			}
		}

		// Get Bounding Box
		var extend = this.map.getExtent();

		// Build URL
		var stringforserver = 
'<?=$mapserver_url;?>&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&Format=image/png&layers=' 
+ layersstring.join(",") + '&BBOX='+ extend.left + ',' + extend.bottom+ ',' 
+ extend.right + ',' + extend.top;

		document.getElementById('resultDiv').innerHTML = stringforserver;

		window.open (stringforserver,'PDF');
	}

_________________________________________________________________
Hotmail to go? Get your Hotmail, news, sports and much more! 
http://mobile.msn.com




More information about the Users mailing list