1

I've installed GeoServer's map printing module. I've tested that it works by following the instructions here. Now, I'm using GeoExt.PrintMapPanel, and my code is as shown below:

var mapPanel = new GeoExt.MapPanel({
        renderTo: "mappanel",
        map: map,
        layers: [wms, gLayer, vector],
        center: new OpenLayers.LonLat(21.0936111111, 7.18805555556),
        zoom: 2.5,
        tbar: toolbarItems,
        bbar: [{
            icon: "img/printer.png",
            tooltip: "Print map",
            handler: function() {
                var printDialog = new Ext.Window({
                    autoHeight: true,
                    width: 350,
                    items: [new GeoExt.PrintMapPanel({
                        sourceMap: mapPanel,
                        printProvider: {
                            capabilities: printCapabilities
                        }
                    })],
                    bbar: [{
                        text: "Create PDF",
                        handler: function() {
                            printDialog.items.get(0).print();
                        }
                    }]
                });
                printDialog.show();
            }
        }]
    });

where printCapabilities is http://localhost:8081/geoserver/pdf/info.json?var=printCapabilities, my local installation. I've written this by following the example here.

However, when I try printing, the following error is shown in GeoServer log: org.mapfish.print.JsonMissingException: attribute [spec.pages[0].mapTitle] missing. Any idea on how I can solve this will be appreciated.

  • You can answer your own question and accept it so this question is marked as answered. Alternatively, I can close it for you. – underdark Aug 22 '12 at 13:22
1

I sorted this out by adjusting printProvider to:

var printProvider = new GeoExt.data.PrintProvider({
        url: "http://localhost:8081/geoserver/pdf",
        method: "GET", // "POST" recommended for production use
        capabilities: printCapabilities, // from the info.json script in the html
        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.