<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='rtl'>
<div style="direction: ltr;"><span style="color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 18px; background-color: rgba(248, 248, 248, 0.589844); ">I am trying to add print function to my GeoExt 2 web application, like:</span>
</div><div style="direction: ltr;"><span style="color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 18px; background-color: rgba(248, 248, 248, 0.589844); "><br></span></div><div style="direction: ltr;"><a href="http://geoext.github.com/geoext2/examples/printpreview/print-preview.html" rel="nofollow" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; cursor: pointer; color: rgb(88, 159, 210); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; line-height: 18px; background-color: rgba(248, 248, 248, 0.589844); ">http://geoext.github.com/geoext2/examples/printpreview/print-preview.html</a> (Thanks to Christian Mayer)</div><div style="direction: ltr;"><br></div><div style="direction: ltr;"><span style="color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 18px; background-color: rgba(248, 248, 248, 0.589844); ">first I am testing this using the same example urls, so in app.html I add:</span>
</div><div style="direction: ltr;"><span style="color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 18px; background-color: rgba(248, 248, 248, 0.589844); "><br></span></div><div style="direction: ltr;"><pre style="margin-top: 0px; margin-bottom: 10px; padding: 5px; border: 0px; font-size: 12px; vertical-align: baseline; overflow: auto; width: auto; max-height: 600px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; background-color: rgb(238, 238, 238); color: rgb(51, 51, 51); line-height: 18px; "><code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; color: rgb(34, 34, 34); "><b><script type="text/javascript" src="http://demo.opengeo.org/geoserver/pdf/info.json?var=printCapabilities"></script></b></code></pre></div><div style="direction: ltr;"><span style="color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 18px; background-color: rgba(248, 248, 248, 0.589844); ">t</span><span style="background-color: rgba(248, 248, 248, 0.589844); color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 18px; ">hen in my js file :</span></div><div style="direction: ltr;"><span style="background-color: rgba(248, 248, 248, 0.589844); color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 18px; "><br></span></div><div style="direction: ltr;"><pre style="margin-top: 0px; margin-bottom: 10px; padding: 5px; border: 0px; font-size: 12px; vertical-align: baseline; overflow: auto; width: auto; max-height: 600px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; background-color: rgb(238, 238, 238); color: rgb(51, 51, 51); line-height: 18px; "><code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; color: rgb(34, 34, 34); ">printProvider : Ext.create('GeoExt.data.PrintProvider', {
method: "GET",
capabilities: printCapabilities,
customParams: {
mapTitle: "GeoExt Printing Demo",
comment: "This demo shows how to use GeoExt.PrintMapPanel"
}
}),
myP = Ext.create('GeoExt.panel.Map', {
renderTo: "content",
width: 500,
height: 350,
map: {
maxExtent: new OpenLayers.Bounds(
143.835, -43.648,
148.479, -39.574
),
maxResolution: 0.018140625,
projection: "EPSG:4326",
units: 'degrees'
},
layers: [new OpenLayers.Layer.WMS("Tasmania State Boundaries",
"http://demo.opengeo.org/geoserver/wms",
{layers: "topp:tasmania_state_boundaries"},
{singleTile: true
, numZoomLevels: 8
})],
center: [146.56, -41.56],
zoom: 0,
bbar: [{
text: "Print...",
handler: function(){
// A window with the PrintMapPanel, which we can use to adjust
// the print extent before creating the pdf.
printDialog = Ext.create('Ext.Window', {
title: "Print Preview",
layout: "fit",
width: 350,
autoHeight: true,
items: [{
xtype: "gx_printmappanel",
sourceMap: myP,
printProvider: printProvider
}
],
bbar: [{
text: "Create PDF",
handler: function(){ printDialog.items.get(0).print(); }
}]
});
printDialog.show();
}
}]
});</code></pre></div><div style="direction: ltr;"><span style="background-color: rgba(248, 248, 248, 0.589844); color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 18px; "><br></span></div><div style="direction: ltr;"><span style="color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 18px; background-color: rgba(248, 248, 248, 0.589844); ">but I keep getting </span><code style="margin: 0px; padding: 1px 5px; border: 0px; font-size: 14px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; color: rgb(34, 34, 34); background-color: rgb(238, 238, 238); line-height: 18px; "><b>Cannot read property 'capabilities' of undefined</b></code><span style="color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 18px; background-color: rgba(248, 248, 248, 0.589844); "> error. I am not sure what I miss here :(</span>
</div>                                            </div></body>
</html>