3

I am using OpenLayers Tile layer fot my map application. I have WMS layers on map like this:

  • Parcels,
  • Streets,
  • Buildings,
  • Gas Pipes,

I zoom to somewhere on map that all layers are visible. I want to select a region within a rectangle and get view as an image. After get image, I want to put it to PDF. How can I do this?

2 Answers 2

3

Try the Geoserver print module http://docs.geoserver.org/latest/en/user/extensions/printing/index.html

First you have to download the print module (be sure to choose the correct version!) then unzip the downloaded content and put the files to your /WEB-INF/lib/ folder of your Geoserver installation.

Restart Geoserver and check if the config file was generated in YOUR_GEOSERVER_DATA_DIR/printing/config.yaml

If the printing module was installed properly you should be able to retrieve informations from your Geoserver about your print module: http://localhost:8080/geoserver/pdf/info.json

This response you can use to set a variable, lets call it "printCapabilities"

http://localhost:8080/geoserver/pdf/info.json?var=printCapabilities

and use this variable then in combination with GeoExt (http://geoext.org):

printProvider = new GeoExt.data.PrintProvider({
                url: "localhost:8080/geoserver/pdf",
                method: "POST", // "POST" recommended for production use
                capabilities: printCapabilities, // from the info.json script in the html
                customParams: {
                    mapTitle: "Einzugsgebiete Liechtenstein",
                    //comment: "nix"
                    dpi: 300
                }
            });

//Drucken/PDF (Button)
    btnPrint = new Ext.Button({
        iconCls: 'print',
        layout: 'fit',
        tooltip: 'Drucken',
        handler: function() {
            var printDialog = new Ext.Window({
                title: 'Druckvorschau',
                autoHeight: true,
                width: 300,
                items: [
                    new GeoExt.PrintMapPanel({
                        sourceMap: mappanel,
                        printProvider: printProvider
                    /* {
                        capabilities: printCapabilities
                    } */
                })],
                bbar: [{
                    text: "Create PDF",
                    handler: function() {
                        printDialog.items.get(0).print();
                    }
                }]
            });
            printDialog.show();
            }
    });

Here you will find several GeoExt-examples with printing functionality:

http://geoext.org/examples.html

or have a look at the newer Version GeoExt2:

http://geoext.github.io/geoext2/examples/printpreview/print-preview.html

2
  • Thanks for the link. Although this may answer the question now, if the link dies, so too does the answer. Please consider adding additional text to support the link. Otherwise, this may be a good candidate for a comment.
    – Aaron
    Commented Jan 29, 2015 at 18:57
  • 1
    just added some more details ;)
    – Thomas B
    Commented Jan 30, 2015 at 12:07
-2

I use in my project MapfishPrint to print map in pdf or image.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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