-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
84 lines (76 loc) · 2.45 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>WMS2PDF print demo</title>
<link href="main.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<h3>Impressió</h3>
Cal cridar el geoservei print/print.php enviant el paràmetre 'printData' amb el següent JSON per POST (veure funció sendJson). La crida retorna un enllaç al document PDF (funció getPDFLink).<br>
Per veure impressió resultant a PDF prémer: <button type="button" id="go">Cridar servei</button><br/>
<textarea readonly id="seeJson" rows="24" cols="140">
</textarea>
<br>
Seleccionar un dels tres exemples
<button type="button" id="polinya1">Polinya</button>
<button type="button" id="cerdanyola">Cerdanyola</button>
<button type="button" id="wiki">Wikipedra</button>
i prémer "cridar servei"
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script src="print/examples/polinya.js"></script>
<script src="print/examples/cerdanyola.js"></script>
<script src="print/examples/wiki.js"></script>
<script>
var layout = "full";
function getPDFLink(data) {
if (data.error == 0) {
//window.open(data.url,"_blank","menubar=no,toolbar=no,scrollbars=no,status=no,resizable=no");
location.href= "print/print.php?pdfUrl="+data.url;
//window.location = this.printServerUrl+"?pdfUrl="+data.url;
} else {
alert("Error creating pdf: " + data.text);
}
}
function sendJson() {
$.ajax({
type: "POST",
url: "print/print.php",
data: { printData: JSON.stringify(selectedJson),
layout: layout},
contentType: "application/x-www-form-urlencoded",
dataType: "json",
success: function(data){
getPDFLink(data);
},
failure: function(errMsg) {
alert(errMsg);
}
});
}
function selectExample(newJson) {
selectedJson = newJson;
var str = JSON.stringify(selectedJson, undefined, 2); // indentation level = 2
$("#seeJson").html(str);
}
$( document ).ready(function() {
selectExample(json);
$("#go").click(function() {
sendJson(json);
});
$("#polinya1").click(function() {
selectExample(json);
layout = "fullpage";
});
$("#cerdanyola").click(function() {
selectExample(json2);
layout = "default";
});
$("#wiki").click(function() {
selectExample(json3);
layout = "default";
});
});
</script>
</body>
</html>