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?

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

  • 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 Jan 29 '15 at 18:57
  • 1
    just added some more details ;) – Thomas B Jan 30 '15 at 12:07
-2

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

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

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.