'Is it possible to print more than one layer with mapfish print servlet

I have a problem with the mapfish print-servlet and the layers of the geowebcache server. (more information: http://www.mapfish.org/doc/print/index.html)

If I try to send one layer in the "spec"-data as POST - request it works fine. If I use the other layer it works fine, too.

My problem is that I want both layers shown in the same picture of the PDF.

I tried it with

layers: [{
                    baseURL:"hier steht die url",
                    opacity:1,
                    singleTile:true,
                    customParams:{
                        TRANSPARENT:true
                    },
                    type:"WMS",
                    layers:
                    ["Strom"],
                    format:"image/png"
                },
                {baseURL:"hier steht die url",
                    opacity:1,
                    singleTile:true,
                    customParams:{
                        TRANSPARENT:true
                    },
                    type:"WMS",
                    layers:
                    ["Kataster"],
                    format:"image/png"
                }
                ]

and this

layers: [{
                    baseURL:""hier steht die url"",
                    opacity:1,
                    singleTile:true,
                    customParams:{
                        TRANSPARENT:true
                    },
                    type:"WMS",
                    layers:
                    ["Kataster", "Strom"],
                    format:"image/png"
                }

Both didn't work. I just get a Message in the PDF that the layer Kaster,Strom could not be found.

So it is not read as an array (just as a String).

This are my full spec data.

  var jsSpec = {
                layout: "A4 portrait",
                title: "Demo MGC PDF",
                srs : "EPSG:900913",
                units : "dd",
                outputFilename :  "PrintFile",
                outputFormat : "pdf",
                layersMerging:true,
                layers: [{
                    baseURL:"hier steht die url",
                    opacity:1,
                    singleTile:true,
                    customParams:{
                        TRANSPARENT:true
                    },
                    type:"WMS",
                    layers:
                    ["Strom"],
                    format:"image/png"
                },
                {baseURL:"hier steht die url",
                    opacity:1,
                    singleTile:true,
                    customParams:{
                        TRANSPARENT:true
                    },
                    type:"WMS",
                    layers:
                    ["Kataster"],
                    format:"image/png"
                }
                ],
                pages : [{
                    center: [959585.51046, 6390630.44659],
                    scale: 64000000,
                    dpi: 190,
                    mapTitle: printFormPanel.getForm().findField('titlefieldvalue').getValue(),
                    comment: printFormPanel.getForm().findField('commentfieldvalue').getValue(),
                    data: [{
                        id : 1, 
                        name: "blah", 
                        icon: "icon_pan"
                    },{
                        id : 2, 
                        name: "blip", 
                        icon: "icon_pan"
                    }]
                }]
            };

This is my full config file:

layouts:     
A4 portrait:
mainPage:
  rotation: true
  pageSize: A4
  header:
    height: 50
    items:
      - !text
        font: Helvetica
        fontSize: 30
        align: right
        text: '${mapTitle}'
  items:
    - !map
      spacingAfter: 30
      width: 440
      height: 483
    - !text
      text: '${comment}'
      spacingAfter: 30
  footer:
    height: 30
    items:
      - !columns
        items:
          - !text
            backgroundColor: #FFFF00
            align: left
            text: Copyright Firma
          - !text
            align: right
            text: 'Page ${pageNum}'

Can somebody tell me what I'm doing wrong? Is it not possible with the servlet to print more than one layer?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source