1

I am using Geoserver 2.4.2 on windows. The print plugin works properly without the legend block. However if I include the legend block in my spec file, it throws an error.

Following is my spec file:

{
    "units" : "degrees",
    "srs" : "EPSG:4326",
    "layout" : "A4 Landscape",
    "dpi" : 150,
    "mapTitle" : "Map Title",
    "comment" : "Map Comment",
    "resourcesUrl" : "http://localhost/portal/img",
    "layers" : [{
            "baseURL" : "http://localhost:8080/geoserver/wms/",
            "opacity" : 1,
            "singleTile" : false,
            "type" : "WMS",
            "layer" : "portal:geo",
            "tileSize" : [256, 256],
            "format" : "png"
        }
    ],
    "pages" : [{
            "center" : [78.800618943104, 23.871591352951],
            "scale" : 100000,
            "rotation" : 0
        }
    ],
    "legends" : [{
            "name" : "Geo",
            "classes" : [{
                    "name" : "",
                    "icon" : "http://localhost:8080/geoserver/wms?version=1.3.0&TRANSPARENT=TRUE&SERVICE=WMS&REQUEST=GetLegendGraphic&EXCEPTIONS=application/vnd.ogc.se_xml&LAYER=portal:geo&FORMAT=image/png"]}]}]"
                }
            ]
        }
    ]
}

I feel the configuration for config.yaml is correct, since it works without the legend block definition in my spec file. This is my legend block definition on the yaml file:

lastPage:
      pageSize: A4
      landscape: true
      rotation: true
      items:
        - !columns
          absoluteX: 60
          absoluteY: 570
          width: 800
          items:
            - !text
              align: left
              font: Arial
              fontSize: 16
              text: 'Map Legend'
        - !columns
          absoluteX: 60
          absoluteY: 515
          width: 720
          items:
            - !legends
                backgroundColor: #FFFFFF
                borders: true
                horizontalAlignment: left
                inline: true
                maxHeight: 700
                maxWidth: 550
                defaultScale: 0.5
                iconMaxWidth: 80
                iconMaxHeight: 80
                iconPadding: 3 0 0 0
                columnMargin: 10
                classIndentation: 3
                classSpace: 5
                backgroundColor: white
                layerFontSize: 9

If I exclude the legend part in my spec file, it is producing the desired pdf file, with a blank second page. Otherwise it is giving the following error:

Error while generating PDF:

java.lang.RuntimeException: Cannot parse the spec file

  • Have you solved it yet? I am currently fighting the same issue. – Michal Zimmermann Jan 13 '14 at 9:55
2

This error is caused by ampersand not being properly escaped. All you need to do is replacing & with %26.

-1

You have syntax error, check json in http://jsonformatter.curiousconcept.com/.

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.