[OpenLayers-Users] Simple print tool

David Alda Fernandez de Lezea dalda at ikt.es
Wed Apr 7 06:53:05 EDT 2010


Hello,

Maybe is not the best way of doing things, but I managed to get the vector data in a pop up window by doing:

//Take all the svg elements represented in the XHTML
svgList = document.getElementsByTagName("svg");

for (var i=0;i<=svgList.length-1;i++){
	importedNode = document.importNode(svgList[i], true);
	var atributo = importedNode.getAttribute("id").split("_")[0] + "_" + importedNode.getAttribute("id").split("_")[1];
	WinPrint.document.getElementById(atributo).appendChild(importedNode);
}

Whereas 'WinPrint' is the pop-up window that I'm going to print. This works perfect in FireFox.

My problems start when I try to do this in IE:

1) IE does not have the vector elements drawn with SVG, it uses VML, I guess. So instead the first line I've got something like:
	svgList = document.getElementsByTagName("group");
2) IE does not have importNode, so I implemented that method reusing some code I found on the internet, not a problem at all.
3) I tried to do same thing (same idea) I did with FF, but I can only get the raster images, not the vector images, and I get no error.

	for (var i=0;i<=svgList.length-1;i++){
		importedNode = WinPrint.document._importNode(svgList[i], true);
		var atributo = importedNode.getAttribute("id").split("_")[0] + "_" + importedNode.getAttribute("id").split("_")[1];
		WinPrint.document.getElementById(atributo).appendChild(aux);
	}


Can someone help me??

Thanks in advance.



-----Mensaje original-----
De: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] En nombre de David Alda Fernandez de Lezea
Enviado el: viernes, 26 de marzo de 2010 13:29
Para: openlayers users
Asunto: Re: [OpenLayers-Users] Simple print tool

Hi Carsten, 

Thanks for your response. You're right, I've tested printing the view_port without writing it in a popup, and the vector features are shown. The problem now is that I'm passsing to the print method the view_port div, but I get a printed image of all the document, but maybe that's more my task.

Just a question, is it possible to get the SVG objects of these features, and also print them in a window??

Thanks!!

-----Mensaje original-----
De: Carsten Eider [mailto:eider at fh-bingen.de] Enviado el: viernes, 26 de marzo de 2010 12:27
Para: David Alda Fernandez de Lezea
CC: openlayers users
Asunto: Re: [OpenLayers-Users] Simple print tool

Hi David,

from my point of view it is not possible to exchange vectors between windows as it would be a cross-site scripting.
One way could be to send the data to the server and request it again.

Carsten

Am 26.03.2010 09:21, schrieb David Alda Fernandez de Lezea:
> Hi,
>
> I want to accomplish a simple print tool that prints the actual viewport of the application. Until now, I've managed to create a popup window with the viewport and the wms layers that I need, but I can't get some OpenLayers.Vector layers with some features shown in the popup.
>
> Does anybody know how to do this??
>
> Thanks.
>
> Un saludo,
>
> ······································································
> ············
>
> David Alda Fernández de Lezea
> Lurralde eta Biodibertsitate Saila / Dpto. de Territorio y 
> Biodiversidad
>
> IKT
> Granja Modelo s/n · 01192 · Arkaute (Araba)
>
> ··················································································
> Tlfnos.: 945-00-32-95                         Fax: 945-00.32.90
> ··················································································
> email: dalda at ikt.es                                web: www.ikt.es
> ······································································
> ············ _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>    

_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users



More information about the Users mailing list