I´m trying to add a print function to my GeoExt MapPanel, using the following code:

bbar: ["->", {
                    text: "Print...",
                    handler: function() { 
                        var printDialog = new Ext.Window({
                                items: [new GeoExt.PrintMapPanel({
                                    sourceMap: mapPanel,
                                    printProvider: new GeoExt.data.PrintProvider({
                                        method: "GET", 
                                        url: "/geoserver/pdf", 

                                        listeners: {
                                        "loadcapabilities": function() {
                                        var printPage = new GeoExt.data.PrintPage();
                                            printPage.fit(mapPanel, true);
                                            printProvider.print(mapPanel, printPage);
                                            customParams: {
                                                mapTitle: "LVR WebGIS",
                                                comment: "created with GeoExt"
                                bbar: [{
                                    text: "Create PDF",
                                    handler: function() {

Using this code, I get the firebug error message

this.printProvider.layout is null

in line 240 of the PrintMapPanel.js

239  adjustSize: function(width, height) {
240  var printSize = this.printProvider.layout.get("size");
241  var ratio = printSize.width / printSize.height; 

when trying to print the MapPanel.

Do I have to add a size/layout definition somewhere in the code or in the config.yaml of the print provider?


The map definitions should be in the YAML file. These are then accessed through the print web service via the info.json page.


For testing you can always hardcode these parameters by creating a JSON object:

var printCapabilities = {
            "name":"A4 portrait",

You can try this with the GeoExt example at http://api.geoext.org/1.0/examples/print-page.js Replace the printCapabilities with a hard-coded JSON object like above. Once this is working then get the JSON dynamically from the web service.

// The printProvider that connects us to the print service
var printProvider = new GeoExt.data.PrintProvider({
    method: "GET", // "POST" recommended for production use
    capabilities: printCapabilities // from the info.json script in the html
// Our print page. Tells the PrintProvider about the scale and center of
// our page.
printPage = new GeoExt.data.PrintPage({
    printProvider: printProvider,
    customParams: {
        mapTitle: "Printing Demo",
        comment: "This is a simple map printed from GeoExt."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.