[Geoserver-users] How to print legend in Geoserver Print plugin?

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. 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

Hi Arunava,
I don’t know if it’s only a typo, but your json spec has some extra parentheses at the end of the icon property row:

try with this spec:

{
“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
}
]
}
]
}

···

2013/12/12 Arunava Dey <thelastray@anonymised.com>

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. 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


Rapidly troubleshoot problems before they affect your business. Most IT
organizations don’t have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk


Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Hello,

Thanks for your reply. That was indeed a typo. I have checked your spec, also. But I am still getting the same error.

Arunava Dey

···

On Thu, Dec 12, 2013 at 2:26 PM, Mauro Bartolomeoli <maurobartolomeoli@anonymised.com> wrote:

Hi Arunava,
I don’t know if it’s only a typo, but your json spec has some extra parentheses at the end of the icon property row:

try with this spec:

{
“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
}
]
}
]
}

2013/12/12 Arunava Dey <thelastray@anonymised.com>

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. 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


Rapidly troubleshoot problems before they affect your business. Most IT
organizations don’t have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk


Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Hi Arunava, do you have a more complete stack trace in your geoserver.log?

Mauro

···

2013/12/12 Arunava Dey <thelastray@anonymised.com…>

Hello,

Thanks for your reply. That was indeed a typo. I have checked your spec, also. But I am still getting the same error.

Arunava Dey

On Thu, Dec 12, 2013 at 2:26 PM, Mauro Bartolomeoli <maurobartolomeoli@anonymised.com> wrote:

Hi Arunava,
I don’t know if it’s only a typo, but your json spec has some extra parentheses at the end of the icon property row:

try with this spec:

{
“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
}
]
}
]
}

2013/12/12 Arunava Dey <thelastray@anonymised.com>

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. 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


Rapidly troubleshoot problems before they affect your business. Most IT
organizations don’t have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk


Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Hello Mauro,
I am not sure about the geoserver.log.

The following is in my geoserver request log:

fe80:0:0:0:3063:6e1e:52b3:59bb%15 - - [12/Dec/2013:09:49:23 +0000] “GET /geoserver/pdf/print.pdf?spec={%22units%22:%22degrees%22,%22srs%22:%22EPSG:4326%22,%22layout%22:%22A4%20Landscape%22,%22dpi%22:150,%22mapTitle%22:%22Map%20Title%22,%22comment%22:%22Map%20Comment%22,%22resourcesUrl%22:%22http://localhost/portal/img%22,%22layers%22:[{%22baseURL%22:%22http://localhost:8080/geoserver/wms/%22,%22opacity%22:1,%22singleTile%22:false,%22type%22:%22WMS%22,%22layer%22:%22portal:geo%22,%22tileSize%22:[256,256],%22format%22:%22png%22}],%22pages%22:[{%22center%22:[78.800618943104,23.871591352951],%22scale%22:100000,%22rotation%22:0}],%22legends%22:[{%22name%22:%22Geo%22,%22classes%22:[{%22name%22:%22%22,%22icon%22:%22http://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%22}]}]} HTTP/1.1” 500 1379

And the following is displayed on my browser:

Error while generating PDF:
java.lang.RuntimeException: Cannot parse the spec file
	at org.mapfish.print.MapPrinter.parseSpec(MapPrinter.java:156)
	at org.mapfish.print.servlet.MapPrinterServlet.doCreatePDFFile(MapPrinterServlet.java:264)
	at org.mapfish.print.servlet.MapPrinterServlet.createAndGetPDF(MapPrinterServlet.java:130)
	at org.mapfish.print.servlet.MapPrinterServlet.doGet(MapPrinterServlet.java:68)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.springframework.web.servlet.mvc.ServletWrappingController.handleRequestInternal(ServletWrappingController.java:159)
	at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
	at org.geoserver.filters.ThreadLocalsCleanupFilter.doFilter(ThreadLocalsCleanupFilter.java:27)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.filters.SpringDelegatingFilter$Chain.doFilter(SpringDelegatingFilter.java:74)
	at org.geoserver.filters.SpringDelegatingFilter.doFilter(SpringDelegatingFilter.java:45)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.platform.AdvancedDispatchFilter.doFilter(AdvancedDispatchFilter.java:49)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72)
	at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72)
	at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.geoserver.security.filter.GeoServerAnonymousAuthenticationFilter.doFilter(GeoServerAnonymousAuthenticationFilter.java:53)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68)
	at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72)
	at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
	at org.geoserver.security.filter.GeoServerBasicAuthenticationFilter.doFilter(GeoServerBasicAuthenticationFilter.java:82)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
	at org.geoserver.security.filter.GeoServerSecurityContextPersistenceFilter$1.doFilter(GeoServerSecurityContextPersistenceFilter.java:52)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72)
	at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)
	at org.geoserver.security.GeoServerSecurityFilterChainProxy.doFilter(GeoServerSecurityFilterChainProxy.java:134)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:75)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:42)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.filters.SessionDebugFilter.doFilter(SessionDebugFilter.java:47)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.filters.FlushSafeFilter.doFilter(FlushSafeFilter.java:43)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.vfny.geoserver.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:109)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
	at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
	at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.Server.handle(Server.java:324)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:828)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
	at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
Caused by: org.json.JSONException: Unterminated string at character 513
	at org.json.JSONTokener.syntaxError(JSONTokener.java:410)
	at org.json.JSONTokener.nextString(JSONTokener.java:244)
	at org.json.JSONTokener.nextValue(JSONTokener.java:341)
	at org.json.JSONObject.<init>(JSONObject.java:205)
	at org.json.JSONTokener.nextValue(JSONTokener.java:344)
	at org.json.JSONArray.<init>(JSONArray.java:125)
	at org.json.JSONTokener.nextValue(JSONTokener.java:348)
	at org.json.JSONObject.<init>(JSONObject.java:205)
	at org.json.JSONTokener.nextValue(JSONTokener.java:344)
	at org.json.JSONArray.<init>(JSONArray.java:125)
	at org.json.JSONTokener.nextValue(JSONTokener.java:348)
	at org.json.JSONObject.<init>(JSONObject.java:205)
	at org.json.JSONObject.<init>(JSONObject.java:402)
	at org.mapfish.print.MapPrinter.parseSpec(MapPrinter.java:154)
	... 80 more

Thank you,
Arunava Dey
···

On Thu, Dec 12, 2013 at 2:56 PM, Mauro Bartolomeoli <mauro.bartolomeoli@anonymised.com> wrote:

Hi Arunava, do you have a more complete stack trace in your geoserver.log?

Mauro

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


2013/12/12 Arunava Dey <thelastray@anonymised.com>

Hello,

Thanks for your reply. That was indeed a typo. I have checked your spec, also. But I am still getting the same error.

Arunava Dey

On Thu, Dec 12, 2013 at 2:26 PM, Mauro Bartolomeoli <maurobartolomeoli@anonymised.com> wrote:

Hi Arunava,
I don’t know if it’s only a typo, but your json spec has some extra parentheses at the end of the icon property row:

try with this spec:

{
“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
}
]
}
]
}

2013/12/12 Arunava Dey <thelastray@anonymised.com>

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. 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


Rapidly troubleshoot problems before they affect your business. Most IT
organizations don’t have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk


Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Oooopssss!!! I am sorry. Please ignore the previous mail.

The following is in my geoserver request log:

fe80:0:0:0:3063:6e1e:52b3:59bb%15 - - [12/Dec/2013:09:58:11 +0000] “GET /geoserver/pdf/print.pdf?spec={%22units%22:%22degrees%22,%22srs%22:%22EPSG:4326%22,%22layout%22:%22A4%20Landscape%22,%22dpi%22:150,%22mapTitle%22:%22MP%20GeoPortal%20Map%22,%22comment%22:%22This%20map%20is%20printed%20using%20MP%20GeoPortal.%22,%22resourcesUrl%22:%22http://localhost/mpgeoportal/img%22,%22layers%22:[{%22baseURL%22:%22http://localhost:8080/geoserver/mpgeoportal/wms%22,%22opacity%22:1,%22singleTile%22:true,%22type%22:%22WMS%22,%22layers%22:[%22mpgeoportal:sagar_geomorphology%22],%22format%22:%22image/png%22,%22styles%22:[%22%22],%22customParams%22:{%22TRANSPARENT%22:true}}],%22pages%22:[{%22center%22:[78.800618943104,23.871591352951],%22scale%22:100000,%22rotation%22:0}],%22legends%22:[{%22name%22:%22Geomorphology%22,%22classes%22:[{%22name%22:%22%22,%22icons%22:%22http://localhost:8080/geoserver/mpgeoportal/wms?version=1.3.0&TRANSPARENT=TRUE&SERVICE=WMS&REQUEST=GetLegendGraphic&EXCEPTIONS=application/vnd.ogc.se_xml&LAYER=mpgeompgeoportal:sagar_geomorphology&FORMAT=image/png%22}]}]} HTTP/1.1” 500 1378

And the following is displayed on my browser:

geoserver-GetLegendGraphic.png

···

On Thu, Dec 12, 2013 at 3:21 PM, Arunava Dey <thelastray@anonymised.com> wrote:

Hello Mauro,
I am not sure about the geoserver.log.

The following is in my geoserver request log:

fe80:0:0:0:3063:6e1e:52b3:59bb%15 - - [12/Dec/2013:09:49:23 +0000] “GET /geoserver/pdf/print.pdf?spec={%22units%22:%22degrees%22,%22srs%22:%22EPSG:4326%22,%22layout%22:%22A4%20Landscape%22,%22dpi%22:150,%22mapTitle%22:%22Map%20Title%22,%22comment%22:%22Map%20Comment%22,%22resourcesUrl%22:%22http://localhost/portal/img%22,%22layers%22:[{%22baseURL%22:%22http://localhost:8080/geoserver/wms/%22,%22opacity%22:1,%22singleTile%22:false,%22type%22:%22WMS%22,%22layer%22:%22portal:geo%22,%22tileSize%22:[256,256],%22format%22:%22png%22}],%22pages%22:[{%22center%22:[78.800618943104,23.871591352951],%22scale%22:100000,%22rotation%22:0}],%22legends%22:[{%22name%22:%22Geo%22,%22classes%22:[{%22name%22:%22%22,%22icon%22:%22http://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%22}]}]} HTTP/1.1” 500 1379

And the following is displayed on my browser:

Error while generating PDF:
java.lang.RuntimeException: Cannot parse the spec file
	at org.mapfish.print.MapPrinter.parseSpec(MapPrinter.java:156)
	at org.mapfish.print.servlet.MapPrinterServlet.doCreatePDFFile(MapPrinterServlet.java:264)
	at org.mapfish.print.servlet.MapPrinterServlet.createAndGetPDF(MapPrinterServlet.java:130)
	at org.mapfish.print.servlet.MapPrinterServlet.doGet(MapPrinterServlet.java:68)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.springframework.web.servlet.mvc.ServletWrappingController.handleRequestInternal(ServletWrappingController.java:159)
	at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
	at org.geoserver.filters.ThreadLocalsCleanupFilter.doFilter(ThreadLocalsCleanupFilter.java:27)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.filters.SpringDelegatingFilter$Chain.doFilter(SpringDelegatingFilter.java:74)
	at org.geoserver.filters.SpringDelegatingFilter.doFilter(SpringDelegatingFilter.java:45)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.platform.AdvancedDispatchFilter.doFilter(AdvancedDispatchFilter.java:49)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72)
	at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72)
	at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.geoserver.security.filter.GeoServerAnonymousAuthenticationFilter.doFilter(GeoServerAnonymousAuthenticationFilter.java:53)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68)
	at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72)
	at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
	at org.geoserver.security.filter.GeoServerBasicAuthenticationFilter.doFilter(GeoServerBasicAuthenticationFilter.java:82)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
	at org.geoserver.security.filter.GeoServerSecurityContextPersistenceFilter$1.doFilter(GeoServerSecurityContextPersistenceFilter.java:52)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72)
	at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)
	at org.geoserver.security.GeoServerSecurityFilterChainProxy.doFilter(GeoServerSecurityFilterChainProxy.java:134)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:75)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:42)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.filters.SessionDebugFilter.doFilter(SessionDebugFilter.java:47)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.filters.FlushSafeFilter.doFilter(FlushSafeFilter.java:43)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.vfny.geoserver.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:109)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
	at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
	at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.Server.handle(Server.java:324)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:828)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
	at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
Caused by: org.json.JSONException: Unterminated string at character 513
	at org.json.JSONTokener.syntaxError(JSONTokener.java:410)
	at org.json.JSONTokener.nextString(JSONTokener.java:244)
	at org.json.JSONTokener.nextValue(JSONTokener.java:341)
	at org.json.JSONObject.<init>(JSONObject.java:205)
	at org.json.JSONTokener.nextValue(JSONTokener.java:344)
	at org.json.JSONArray.<init>(JSONArray.java:125)
	at org.json.JSONTokener.nextValue(JSONTokener.java:348)
	at org.json.JSONObject.<init>(JSONObject.java:205)
	at org.json.JSONTokener.nextValue(JSONTokener.java:344)
	at org.json.JSONArray.<init>(JSONArray.java:125)
	at org.json.JSONTokener.nextValue(JSONTokener.java:348)
	at org.json.JSONObject.<init>(JSONObject.java:205)
	at org.json.JSONObject.<init>(JSONObject.java:402)
	at org.mapfish.print.MapPrinter.parseSpec(MapPrinter.java:154)
	... 80 more

Thank you,
Arunava Dey

On Thu, Dec 12, 2013 at 2:56 PM, Mauro Bartolomeoli <mauro.bartolomeoli@anonymised.com> wrote:

Hi Arunava, do you have a more complete stack trace in your geoserver.log?

Mauro

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


2013/12/12 Arunava Dey <thelastray@anonymised.com>

Hello,

Thanks for your reply. That was indeed a typo. I have checked your spec, also. But I am still getting the same error.

Arunava Dey

On Thu, Dec 12, 2013 at 2:26 PM, Mauro Bartolomeoli <maurobartolomeoli@anonymised.com> wrote:

Hi Arunava,
I don’t know if it’s only a typo, but your json spec has some extra parentheses at the end of the icon property row:

try with this spec:

{
“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
}
]
}
]
}

2013/12/12 Arunava Dey <thelastray@anonymised.com>

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. 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


Rapidly troubleshoot problems before they affect your business. Most IT
organizations don’t have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk


Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Hello,

I am still struggling to print my map layer legends. Following is my spec file, encoded URL for icons as suggested by Mauro:
{
“units” : “degrees”,
“srs” : “EPSG:4326”,
“layout” : “A4 Landscape”,
“dpi” : 150,
“mapTitle” : “MP GeoPortal Map”,
“comment” : “This map is printed using MP GeoPortal.”,
“resourcesUrl” : “http://localhost/mpgeoportal/img”,
“layers” : [{
“baseURL” : “http://localhost:8080/geoserver/mpgeoportal/wms”,
“opacity” : 1,
“singleTile” : true,
“type” : “WMS”,
“layers” : [“mpgeoportal:sagar_geomorphology”],
“format” : “image/png”,
“styles” : [“”],
“customParams” : {
“TRANSPARENT” : true
}
}
],
“pages” : [{
“center” : [78.800618943104, 23.871591352951],
“scale” : 100000,
“rotation” : 0
}
],
“legends” : [{
“name” : “Geomorphology”,
“classes” : [{
“name” : “”,
“icons” : “http%3A%2F%2Flocalhost%3A8080%2Fgeoserver%2Fmpgeoportal%2Fwms%3Fversion%3D1.3.0%26TRANSPARENT%3DTRUE%26SERVICE%3DWMS%26REQUEST%3DGetLegendGraphic%26EXCEPTIONS%3Dapplication%2Fvnd.ogc.se_xml%26LAYER%3Dmpgeompgeoportal%3Asagar_geomorphology%26FORMAT%3Dimage%2Fpng”
}
]
}
]
}

I am having doubts about the name and icons block in legend definition. Is it for individual classes in my layer or it is for the entire layer? For example, for my geomorphology layer, I have, say 15 classes, namely g1, g2, g3 and so on. What should be the content for name block within classes. I am leaving it blank. Also the URL in icons gives the legend graphic for the entire layer (g1, g2…).

Arunava Dey

geoserver-GetLegendGraphic.png

···

On Thu, Dec 12, 2013 at 3:58 PM, Arunava Dey <thelastray@anonymised.com> wrote:

Hmmm…
A bit better. Now it is printing the layer name in the legend block, but not legend graphic.

Thanking you,
Arunava Dey

On Thu, Dec 12, 2013 at 3:50 PM, Mauro Bartolomeoli <mauro.bartolomeoli@anonymised.com> wrote:

Hi Arunava,
I think you need to encode the URL, use something like this:

http%3A%2F%2Flocalhost%3A8080%2Fgeoserver%2Fmpgeoportal%2Fwms%3Fversion%3D1.3.0%26TRANSPARENT%3DTRUE%26SERVICE%3DWMS%26REQUEST%3DGetLegendGraphic%26EXCEPTIONS%3Dapplication%2Fvnd.ogc.se_xml%26LAYER%3Dmpgeompgeoportal%3Asagar_geomorphology%26FORMAT%3Dimage%2Fpng

instead of

http://localhost:8080/geoserver/mpgeoportal/wms?version=1.3.0&TRANSPARENT=TRUE&SERVICE=WMS&REQUEST=GetLegendGraphic&EXCEPTIONS=application/vnd.ogc.se_xml&LAYER=mpgeompgeoportal:sagar_geomorphology&FORMAT=image/png

Regards,
Mauro Bartolomeoli

2013/12/12 Arunava Dey <thelastray@anonymised.com>

Oooopssss!!! I am sorry. Please ignore the previous mail.

The following is in my geoserver request log:

fe80:0:0:0:3063:6e1e:52b3:59bb%15 - - [12/Dec/2013:09:58:11 +0000] “GET /geoserver/pdf/print.pdf?spec={%22units%22:%22degrees%22,%22srs%22:%22EPSG:4326%22,%22layout%22:%22A4%20Landscape%22,%22dpi%22:150,%22mapTitle%22:%22MP%20GeoPortal%20Map%22,%22comment%22:%22This%20map%20is%20printed%20using%20MP%20GeoPortal.%22,%22resourcesUrl%22:%22http://localhost/mpgeoportal/img%22,%22layers%22:[{%22baseURL%22:%22http://localhost:8080/geoserver/mpgeoportal/wms%22,%22opacity%22:1,%22singleTile%22:true,%22type%22:%22WMS%22,%22layers%22:[%22mpgeoportal:sagar_geomorphology%22],%22format%22:%22image/png%22,%22styles%22:[%22%22],%22customParams%22:{%22TRANSPARENT%22:true}}],%22pages%22:[{%22center%22:[78.800618943104,23.871591352951],%22scale%22:100000,%22rotation%22:0}],%22legends%22:[{%22name%22:%22Geomorphology%22,%22classes%22:[{%22name%22:%22%22,%22icons%22:%22http://localhost:8080/geoserver/mpgeoportal/wms?version=1.3.0&TRANSPARENT=TRUE&SERVICE=WMS&REQUEST=GetLegendGraphic&EXCEPTIONS=application/vnd.ogc.se_xml&LAYER=mpgeompgeoportal:sagar_geomorphology&FORMAT=image/png%22}]}]} HTTP/1.1” 500 1378

And the following is displayed on my browser:


```

Error while generating PDF:
java.lang.RuntimeException: Cannot parse the spec file
	at org.mapfish.print.MapPrinter.parseSpec(MapPrinter.java:156)
	at org.mapfish.print.servlet.MapPrinterServlet.doCreatePDFFile(MapPrinterServlet.java:264)
	at org.mapfish.print.servlet.MapPrinterServlet.createAndGetPDF(MapPrinterServlet.java:130)
	at org.mapfish.print.servlet.MapPrinterServlet.doGet(MapPrinterServlet.java:68)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.springframework.web.servlet.mvc.ServletWrappingController.handleRequestInternal(ServletWrappingController.java:159)
	at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
	at org.geoserver.filters.ThreadLocalsCleanupFilter.doFilter(ThreadLocalsCleanupFilter.java:27)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.filters.SpringDelegatingFilter$Chain.doFilter(SpringDelegatingFilter.java:74)
	at org.geoserver.filters.SpringDelegatingFilter.doFilter(SpringDelegatingFilter.java:45)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.platform.AdvancedDispatchFilter.doFilter(AdvancedDispatchFilter.java:49)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72)
	at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72)
	at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.geoserver.security.filter.GeoServerAnonymousAuthenticationFilter.doFilter(GeoServerAnonymousAuthenticationFilter.java:53)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68)
	at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72)
	at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
	at org.geoserver.security.filter.GeoServerBasicAuthenticationFilter.doFilter(GeoServerBasicAuthenticationFilter.java:82)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
	at org.geoserver.security.filter.GeoServerSecurityContextPersistenceFilter$1.doFilter(GeoServerSecurityContextPersistenceFilter.java:52)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72)
	at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)
	at org.geoserver.security.GeoServerSecurityFilterChainProxy.doFilter(GeoServerSecurityFilterChainProxy.java:134)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:75)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:42)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.filters.SessionDebugFilter.doFilter(SessionDebugFilter.java:47)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.filters.FlushSafeFilter.doFilter(FlushSafeFilter.java:43)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.vfny.geoserver.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:109)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
	at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
	at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.Server.handle(Server.java:324)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:828)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
	at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:

450)
Caused by: org.json.JSONException: Unterminated string at character 645
	at org.json.JSONTokener.syntaxError(JSONTokener.java:410)
	at org.json.JSONTokener.nextString(JSONTokener.java:244)
	at org.json.JSONTokener.nextValue(JSONTokener.java:341)
	at org.json.JSONObject.<init>(JSONObject.java:205)
	at org.json.JSONTokener.nextValue(JSONTokener.java:344)
	at org.json.JSONArray.<init>(JSONArray.java:125)
	at org.json.JSONTokener.nextValue(JSONTokener.java:348)
	at org.json.JSONObject.<init>(JSONObject.java:205)
	at org.json.JSONTokener.nextValue(JSONTokener.java:344)
	at org.json.JSONArray.<init>(JSONArray.java:125)
	at org.json.JSONTokener.nextValue(JSONTokener.java:348)
	at org.json.JSONObject.<init>(JSONObject.java:205)
	at org.json.JSONObject.<init>(JSONObject.java:402)
	at org.mapfish.print.MapPrinter.parseSpec(MapPrinter.java:154)
	... 80 more
```

```

```

```
The icon URL is producing the following image:
```

```
<img src="cid:ii_142e63fc2a67715a" alt="Inline image 1">

```

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


On Thu, Dec 12, 2013 at 3:21 PM, Arunava Dey <thelastray@anonymised.com> wrote:

Hello Mauro,
I am not sure about the geoserver.log.

The following is in my geoserver request log:

fe80:0:0:0:3063:6e1e:52b3:59bb%15 - - [12/Dec/2013:09:49:23 +0000] “GET /geoserver/pdf/print.pdf?spec={%22units%22:%22degrees%22,%22srs%22:%22EPSG:4326%22,%22layout%22:%22A4%20Landscape%22,%22dpi%22:150,%22mapTitle%22:%22Map%20Title%22,%22comment%22:%22Map%20Comment%22,%22resourcesUrl%22:%22http://localhost/portal/img%22,%22layers%22:[{%22baseURL%22:%22http://localhost:8080/geoserver/wms/%22,%22opacity%22:1,%22singleTile%22:false,%22type%22:%22WMS%22,%22layer%22:%22portal:geo%22,%22tileSize%22:[256,256],%22format%22:%22png%22}],%22pages%22:[{%22center%22:[78.800618943104,23.871591352951],%22scale%22:100000,%22rotation%22:0}],%22legends%22:[{%22name%22:%22Geo%22,%22classes%22:[{%22name%22:%22%22,%22icon%22:%22http://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%22}]}]} HTTP/1.1” 500 1379

And the following is displayed on my browser:

Error while generating PDF:
java.lang.RuntimeException: Cannot parse the spec file
	at org.mapfish.print.MapPrinter.parseSpec(MapPrinter.java:156)
	at org.mapfish.print.servlet.MapPrinterServlet.doCreatePDFFile(MapPrinterServlet.java:264)
	at org.mapfish.print.servlet.MapPrinterServlet.createAndGetPDF(MapPrinterServlet.java:130)
	at org.mapfish.print.servlet.MapPrinterServlet.doGet(MapPrinterServlet.java:68)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.springframework.web.servlet.mvc.ServletWrappingController.handleRequestInternal(ServletWrappingController.java:159)
	at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
	at org.geoserver.filters.ThreadLocalsCleanupFilter.doFilter(ThreadLocalsCleanupFilter.java:27)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.filters.SpringDelegatingFilter$Chain.doFilter(SpringDelegatingFilter.java:74)
	at org.geoserver.filters.SpringDelegatingFilter.doFilter(SpringDelegatingFilter.java:45)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.platform.AdvancedDispatchFilter.doFilter(AdvancedDispatchFilter.java:49)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72)
	at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72)
	at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.geoserver.security.filter.GeoServerAnonymousAuthenticationFilter.doFilter(GeoServerAnonymousAuthenticationFilter.java:53)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68)
	at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72)
	at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
	at org.geoserver.security.filter.GeoServerBasicAuthenticationFilter.doFilter(GeoServerBasicAuthenticationFilter.java:82)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
	at org.geoserver.security.filter.GeoServerSecurityContextPersistenceFilter$1.doFilter(GeoServerSecurityContextPersistenceFilter.java:52)
	at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72)
	at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)
	at org.geoserver.security.GeoServerSecurityFilterChainProxy.doFilter(GeoServerSecurityFilterChainProxy.java:134)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:75)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:42)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.filters.SessionDebugFilter.doFilter(SessionDebugFilter.java:47)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.geoserver.filters.FlushSafeFilter.doFilter(FlushSafeFilter.java:43)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.vfny.geoserver.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:109)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
	at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
	at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.Server.handle(Server.java:324)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:828)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
	at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
Caused by: org.json.JSONException: Unterminated string at character 513
	at org.json.JSONTokener.syntaxError(JSONTokener.java:410)
	at org.json.JSONTokener.nextString(JSONTokener.java:244)
	at org.json.JSONTokener.nextValue(JSONTokener.java:341)
	at org.json.JSONObject.<init>(JSONObject.java:205)
	at org.json.JSONTokener.nextValue(JSONTokener.java:344)
	at org.json.JSONArray.<init>(JSONArray.java:125)
	at org.json.JSONTokener.nextValue(JSONTokener.java:348)
	at org.json.JSONObject.<init>(JSONObject.java:205)
	at org.json.JSONTokener.nextValue(JSONTokener.java:344)
	at org.json.JSONArray.<init>(JSONArray.java:125)
	at org.json.JSONTokener.nextValue(JSONTokener.java:348)
	at org.json.JSONObject.<init>(JSONObject.java:205)
	at org.json.JSONObject.<init>(JSONObject.java:402)
	at org.mapfish.print.MapPrinter.parseSpec(MapPrinter.java:154)
	... 80 more

Thank you,
Arunava Dey

On Thu, Dec 12, 2013 at 2:56 PM, Mauro Bartolomeoli <mauro.bartolomeoli@anonymised.com> wrote:

Hi Arunava, do you have a more complete stack trace in your geoserver.log?

Mauro

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


2013/12/12 Arunava Dey <thelastray@anonymised.com>

Hello,

Thanks for your reply. That was indeed a typo. I have checked your spec, also. But I am still getting the same error.

Arunava Dey

On Thu, Dec 12, 2013 at 2:26 PM, Mauro Bartolomeoli <maurobartolomeoli@anonymised.com> wrote:

Hi Arunava,
I don’t know if it’s only a typo, but your json spec has some extra parentheses at the end of the icon property row:

try with this spec:

{
“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
}
]
}
]
}

2013/12/12 Arunava Dey <thelastray@anonymised.com>

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. 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


Rapidly troubleshoot problems before they affect your business. Most IT
organizations don’t have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk


Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

2013/12/13 Arunava Dey <thelastray@anonymised.com>

Hello,

I am still struggling to print my map layer legends. Following is my spec
file, encoded URL for icons as suggested by Mauro:
{
"units" : "degrees",
"srs" : "EPSG:4326",
"layout" : "A4 Landscape",
"dpi" : 150,
"mapTitle" : "MP GeoPortal Map",
"comment" : "This map is printed using MP GeoPortal.",
"resourcesUrl" : "http://localhost/mpgeoportal/img&quot;,
"layers" : [{
"baseURL" : "http://localhost:8080/geoserver/mpgeoportal/wms&quot;,
"opacity" : 1,
"singleTile" : true,
"type" : "WMS",
"layers" : ["mpgeoportal:sagar_geomorphology"],
"format" : "image/png",
"styles" : [""],
"customParams" : {
"TRANSPARENT" : true
}
}
],
"pages" : [{
"center" : [78.800618943104, 23.871591352951],
"scale" : 100000,
"rotation" : 0
}
],
"legends" : [{
"name" : "Geomorphology",
"classes" : [{
"name" : "",
"icons" :
"http%3A%2F%2Flocalhost%3A8080%2Fgeoserver%2Fmpgeoportal%2Fwms%3Fversion%3D1.3.0%26TRANSPARENT%3DTRUE%26SERVICE%3DWMS%26REQUEST%3DGetLegendGraphic%26EXCEPTIONS%3Dapplication%2Fvnd.ogc.se_xml%26LAYER%3Dmpgeompgeoportal%3Asagar_geomorphology%26FORMAT%3Dimage%2Fpng"
}
]
}
]
}

I can see one more inconsistency: from the documentation examples (
http://www.mapfish.org/doc/print/protocol.html#print-pdf) the "icons"
property should be an array, so it should be written "icons": ["..."].

I am having doubts about the name and icons block in legend definition. Is
it for individual classes in my layer or it is for the entire layer? For
example, for my geomorphology layer, I have, say 15 classes, namely g1, g2,
g3 and so on. What should be the content for name block within classes. I
am leaving it blank. Also the URL in icons gives the legend graphic for the
entire layer (g1, g2...).

It depends on how you organize your layers/styles. From what I have seen,
you have a single GetLegendGraphic call that is giving you back a set of
icons (one for each Rule in the style) in a single image. In this use case
you have one layer (Geomorphology) and only one class for the entire layer
(rules are managed server side by GeoServer). This class has only one icon
and no name (the rule names are also contained in the icons image).
Mapfish-print allows you also to build your legend client side, by having a
layer with many classes, each with a label on a side (before or after the
icons) and a set of icons, each with its url.

Regards,
Mauro Bartolomeoli

--

Our support, Your Success! Visit http://opensdi.geo-solutions.it for more
information.

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

Hello,

I know this weird… Atlast got it to print the layer legend, but its too small to read. I am not getting what is going wrong. This what I am using:

{
“units”: “degrees”,
“srs”: “EPSG:4326”,
“layout”: “A4 Landscape”,
“dpi”: 150,
“mapTitle”: “MP GeoPortal Map”,
“comment”: “This map is printed using MP GeoPortal.”,
“resourcesUrl”: “http://localhost/mpgeoportal/img”,
“layers”: [
{
“baseURL”: “http://localhost:8080/geoserver/mpgeoportal/wms”,
“opacity”: 1,
“singleTile”: true,
“type”: “WMS”,
“layers”: [“mpgeoportal:sagar_geomorphology”],
“format”: “image/png”,
“styles”: [“”],
“customParams”: {
“TRANSPARENT”: true
}
}
],
“pages”: [{
“center”: [
78.800618943104,
23.871591352951
],
“scale”: 100000,
“rotation”: 0
}
],
“legends”: [
{
“name”: “Geomorphology”,
“classes”: [
{
“name” : “”,
“iconBeforeName”: true,
“icon”: “http%3A%2F%2Framtech-311%3A8080%2Fgeoserver%2Fmpgeoportal%2Fwms%3Fversion%3D1.3.0%26transpaparent%3Dtrue%26REQUEST%3DGetLegendGraphic%26EXCEPTIONS%3Dapplication%2Fvnd.ogc.se_xml%26ICON%3Dgeomorphology%26FORMAT%3Dimage%2Fpng%26MODE%3Dlegendicon%26layer%3Dmpgeoportal%3Asagar_geomorphology”
}
]
}
]
}

And this is what it is producing.
@Mauro Bartolomeoli My spec file is based on the following page https://github.com/mapfish/mapfish-print/issues/96. I am not very much sure about its contents. I have also checked with “icons” with square brackets. It is still giving the same result. Can you provide me a sample spec file with legend definition for geoserver.

Thanking you,

Arunava Dey

GeoPortal Map.pdf (7.95 KB)

···

On Fri, Dec 13, 2013 at 1:39 PM, Mauro Bartolomeoli <mauro.bartolomeoli@anonymised.com> wrote:

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


2013/12/13 Arunava Dey <thelastray@anonymised.com>

Hello,

I am still struggling to print my map layer legends. Following is my spec file, encoded URL for icons as suggested by Mauro:

{
“units” : “degrees”,
“srs” : “EPSG:4326”,
“layout” : “A4 Landscape”,
“dpi” : 150,

“mapTitle” : “MP GeoPortal Map”,
“comment” : “This map is printed using MP GeoPortal.”,
“resourcesUrl” : “http://localhost/mpgeoportal/img”,
“layers” : [{
“baseURL” : “http://localhost:8080/geoserver/mpgeoportal/wms”,
“opacity” : 1,
“singleTile” : true,
“type” : “WMS”,
“layers” : [“mpgeoportal:sagar_geomorphology”],
“format” : “image/png”,
“styles” : [“”],
“customParams” : {
“TRANSPARENT” : true

}
}
],
“pages” : [{
“center” : [78.800618943104, 23.871591352951],
“scale” : 100000,
“rotation” : 0
}
],
“legends” : [{

“name” : “Geomorphology”,
“classes” : [{
“name” : “”,
“icons” : “http%3A%2F%2Flocalhost%3A8080%2Fgeoserver%2Fmpgeoportal%2Fwms%3Fversion%3D1.3.0%26TRANSPARENT%3DTRUE%26SERVICE%3DWMS%26REQUEST%3DGetLegendGraphic%26EXCEPTIONS%3Dapplication%2Fvnd.ogc.se_xml%26LAYER%3Dmpgeompgeoportal%3Asagar_geomorphology%26FORMAT%3Dimage%2Fpng”
}
]
}
]
}

I can see one more inconsistency: from the documentation examples (http://www.mapfish.org/doc/print/protocol.html#print-pdf) the “icons” property should be an array, so it should be written “icons”: [“…”].

I am having doubts about the name and icons block in legend definition. Is it for individual classes in my layer or it is for the entire layer? For example, for my geomorphology layer, I have, say 15 classes, namely g1, g2, g3 and so on. What should be the content for name block within classes. I am leaving it blank. Also the URL in icons gives the legend graphic for the entire layer (g1, g2…).

It depends on how you organize your layers/styles. From what I have seen, you have a single GetLegendGraphic call that is giving you back a set of icons (one for each Rule in the style) in a single image. In this use case you have one layer (Geomorphology) and only one class for the entire layer (rules are managed server side by GeoServer). This class has only one icon and no name (the rule names are also contained in the icons image).
Mapfish-print allows you also to build your legend client side, by having a layer with many classes, each with a label on a side (before or after the icons) and a set of icons, each with its url.

Regards,
Mauro Bartolomeoli

Hi Arunava,
try to change the iconMaxWidth and/or iconMaxHeight to 0 (zero) in your config.yaml, in the legend block.

Mauro

···

2013/12/13 Arunava Dey <thelastray@anonymised.com>

Hello,

I know this weird… Atlast got it to print the layer legend, but its too small to read. I am not getting what is going wrong. This what I am using:

{
“units”: “degrees”,
“srs”: “EPSG:4326”,
“layout”: “A4 Landscape”,
“dpi”: 150,
“mapTitle”: “MP GeoPortal Map”,
“comment”: “This map is printed using MP GeoPortal.”,
“resourcesUrl”: “http://localhost/mpgeoportal/img”,
“layers”: [
{
“baseURL”: “http://localhost:8080/geoserver/mpgeoportal/wms”,
“opacity”: 1,
“singleTile”: true,
“type”: “WMS”,
“layers”: [“mpgeoportal:sagar_geomorphology”],
“format”: “image/png”,
“styles”: [“”],
“customParams”: {
“TRANSPARENT”: true
}
}
],
“pages”: [{
“center”: [
78.800618943104,
23.871591352951
],
“scale”: 100000,
“rotation”: 0
}
],
“legends”: [
{
“name”: “Geomorphology”,
“classes”: [
{
“name” : “”,

“iconBeforeName”: true,
“icon”: “http%3A%2F%2Framtech-311%3A8080%2Fgeoserver%2Fmpgeoportal%2Fwms%3Fversion%3D1.3.0%26transpaparent%3Dtrue%26REQUEST%3DGetLegendGraphic%26EXCEPTIONS%3Dapplication%2Fvnd.ogc.se_xml%26ICON%3Dgeomorphology%26FORMAT%3Dimage%2Fpng%26MODE%3Dlegendicon%26layer%3Dmpgeoportal%3Asagar_geomorphology”
}
]
}
]
}

And this is what it is producing.
@Mauro Bartolomeoli My spec file is based on the following page https://github.com/mapfish/mapfish-print/issues/96. I am not very much sure about its contents. I have also checked with “icons” with square brackets. It is still giving the same result. Can you provide me a sample spec file with legend definition for geoserver.

Thanking you,

Arunava Dey

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


On Fri, Dec 13, 2013 at 1:39 PM, Mauro Bartolomeoli <mauro.bartolomeoli@anonymised.com> wrote:

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


2013/12/13 Arunava Dey <thelastray@anonymised.com>

Hello,

I am still struggling to print my map layer legends. Following is my spec file, encoded URL for icons as suggested by Mauro:

{
“units” : “degrees”,
“srs” : “EPSG:4326”,
“layout” : “A4 Landscape”,
“dpi” : 150,

“mapTitle” : “MP GeoPortal Map”,
“comment” : “This map is printed using MP GeoPortal.”,
“resourcesUrl” : “http://localhost/mpgeoportal/img”,
“layers” : [{
“baseURL” : “http://localhost:8080/geoserver/mpgeoportal/wms”,
“opacity” : 1,
“singleTile” : true,
“type” : “WMS”,
“layers” : [“mpgeoportal:sagar_geomorphology”],
“format” : “image/png”,
“styles” : [“”],
“customParams” : {
“TRANSPARENT” : true

}
}
],
“pages” : [{
“center” : [78.800618943104, 23.871591352951],
“scale” : 100000,
“rotation” : 0
}
],
“legends” : [{

“name” : “Geomorphology”,
“classes” : [{
“name” : “”,
“icons” : “http%3A%2F%2Flocalhost%3A8080%2Fgeoserver%2Fmpgeoportal%2Fwms%3Fversion%3D1.3.0%26TRANSPARENT%3DTRUE%26SERVICE%3DWMS%26REQUEST%3DGetLegendGraphic%26EXCEPTIONS%3Dapplication%2Fvnd.ogc.se_xml%26LAYER%3Dmpgeompgeoportal%3Asagar_geomorphology%26FORMAT%3Dimage%2Fpng”
}
]
}
]
}

I can see one more inconsistency: from the documentation examples (http://www.mapfish.org/doc/print/protocol.html#print-pdf) the “icons” property should be an array, so it should be written “icons”: [“…”].

I am having doubts about the name and icons block in legend definition. Is it for individual classes in my layer or it is for the entire layer? For example, for my geomorphology layer, I have, say 15 classes, namely g1, g2, g3 and so on. What should be the content for name block within classes. I am leaving it blank. Also the URL in icons gives the legend graphic for the entire layer (g1, g2…).

It depends on how you organize your layers/styles. From what I have seen, you have a single GetLegendGraphic call that is giving you back a set of icons (one for each Rule in the style) in a single image. In this use case you have one layer (Geomorphology) and only one class for the entire layer (rules are managed server side by GeoServer). This class has only one icon and no name (the rule names are also contained in the icons image).
Mapfish-print allows you also to build your legend client side, by having a layer with many classes, each with a label on a side (before or after the icons) and a set of icons, each with its url.

Regards,
Mauro Bartolomeoli

Hello,
I have already tried with iconMaxHeight and/or iconMaxWidth 0. But still getting the same result. This is my config file:

lastPage:
pageSize: A4
landscape: true
rotation: true
items:

  • !columns
    config:
    borderWidth: 1
    cells:
  • borderColor: black
    padding: 267
    absoluteX: 20
    absoluteY: 566
    width: 800
    height: 500
    items:
  • !text
    text: ‘’
    #Legend
  • !columns
    condition: legends
    absoluteX: 24
    absoluteY: 560
    width: 250
    config:
    borderWidth: 1
    cells:
  • borderWidth: 1
    borderColor: #555555
    padding: 5
    items:
  • !legends
    iconMaxWidth: 0
    iconMaxHeight: 0
    maxWidth: 250
    layerFont: Helvetica
    layerFontSize: 8
    classSpace: 2
    classIndentation: 5
    classFont: Helvetica
    classFontSize: 8
    backgroundColor: white
    inline:false

Thanking you,
Arunava Dey

···

On Fri, Dec 13, 2013 at 7:40 PM, Mauro Bartolomeoli <mauro.bartolomeoli@anonymised.com> wrote:

Hi Arunava,
try to change the iconMaxWidth and/or iconMaxHeight to 0 (zero) in your config.yaml, in the legend block.

Mauro

2013/12/13 Arunava Dey <thelastray@anonymised.com>

Hello,

I know this weird… Atlast got it to print the layer legend, but its too small to read. I am not getting what is going wrong. This what I am using:

{
“units”: “degrees”,
“srs”: “EPSG:4326”,
“layout”: “A4 Landscape”,
“dpi”: 150,
“mapTitle”: “MP GeoPortal Map”,
“comment”: “This map is printed using MP GeoPortal.”,
“resourcesUrl”: “http://localhost/mpgeoportal/img”,
“layers”: [
{
“baseURL”: “http://localhost:8080/geoserver/mpgeoportal/wms”,
“opacity”: 1,
“singleTile”: true,
“type”: “WMS”,
“layers”: [“mpgeoportal:sagar_geomorphology”],
“format”: “image/png”,
“styles”: [“”],
“customParams”: {
“TRANSPARENT”: true
}
}
],
“pages”: [{
“center”: [
78.800618943104,
23.871591352951
],
“scale”: 100000,
“rotation”: 0
}
],
“legends”: [
{
“name”: “Geomorphology”,
“classes”: [
{
“name” : “”,

“iconBeforeName”: true,
“icon”: “http%3A%2F%2Framtech-311%3A8080%2Fgeoserver%2Fmpgeoportal%2Fwms%3Fversion%3D1.3.0%26transpaparent%3Dtrue%26REQUEST%3DGetLegendGraphic%26EXCEPTIONS%3Dapplication%2Fvnd.ogc.se_xml%26ICON%3Dgeomorphology%26FORMAT%3Dimage%2Fpng%26MODE%3Dlegendicon%26layer%3Dmpgeoportal%3Asagar_geomorphology”
}
]
}
]
}

And this is what it is producing.
@Mauro Bartolomeoli My spec file is based on the following page https://github.com/mapfish/mapfish-print/issues/96. I am not very much sure about its contents. I have also checked with “icons” with square brackets. It is still giving the same result. Can you provide me a sample spec file with legend definition for geoserver.

Thanking you,

Arunava Dey

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


On Fri, Dec 13, 2013 at 1:39 PM, Mauro Bartolomeoli <mauro.bartolomeoli@anonymised.com> wrote:

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


2013/12/13 Arunava Dey <thelastray@anonymised.com>

Hello,

I am still struggling to print my map layer legends. Following is my spec file, encoded URL for icons as suggested by Mauro:

{
“units” : “degrees”,
“srs” : “EPSG:4326”,
“layout” : “A4 Landscape”,
“dpi” : 150,

“mapTitle” : “MP GeoPortal Map”,
“comment” : “This map is printed using MP GeoPortal.”,
“resourcesUrl” : “http://localhost/mpgeoportal/img”,
“layers” : [{
“baseURL” : “http://localhost:8080/geoserver/mpgeoportal/wms”,
“opacity” : 1,
“singleTile” : true,
“type” : “WMS”,
“layers” : [“mpgeoportal:sagar_geomorphology”],
“format” : “image/png”,
“styles” : [“”],
“customParams” : {
“TRANSPARENT” : true

}
}
],
“pages” : [{
“center” : [78.800618943104, 23.871591352951],
“scale” : 100000,
“rotation” : 0
}
],
“legends” : [{

“name” : “Geomorphology”,
“classes” : [{
“name” : “”,
“icons” : “http%3A%2F%2Flocalhost%3A8080%2Fgeoserver%2Fmpgeoportal%2Fwms%3Fversion%3D1.3.0%26TRANSPARENT%3DTRUE%26SERVICE%3DWMS%26REQUEST%3DGetLegendGraphic%26EXCEPTIONS%3Dapplication%2Fvnd.ogc.se_xml%26LAYER%3Dmpgeompgeoportal%3Asagar_geomorphology%26FORMAT%3Dimage%2Fpng”
}
]
}
]
}

I can see one more inconsistency: from the documentation examples (http://www.mapfish.org/doc/print/protocol.html#print-pdf) the “icons” property should be an array, so it should be written “icons”: [“…”].

I am having doubts about the name and icons block in legend definition. Is it for individual classes in my layer or it is for the entire layer? For example, for my geomorphology layer, I have, say 15 classes, namely g1, g2, g3 and so on. What should be the content for name block within classes. I am leaving it blank. Also the URL in icons gives the legend graphic for the entire layer (g1, g2…).

It depends on how you organize your layers/styles. From what I have seen, you have a single GetLegendGraphic call that is giving you back a set of icons (one for each Rule in the style) in a single image. In this use case you have one layer (Geomorphology) and only one class for the entire layer (rules are managed server side by GeoServer). This class has only one icon and no name (the rule names are also contained in the icons image).
Mapfish-print allows you also to build your legend client side, by having a layer with many classes, each with a label on a side (before or after the icons) and a set of icons, each with its url.

Regards,
Mauro Bartolomeoli

Hi Arunava

This transmission is intended for the named addressee(s) only and may contain sensitive or protectively marked material up to RESTRICTED and should be handled accordingly. Unless you are the named addressee (or authorised to receive it for the addressee) you may not copy or use it, or disclose it to anyone else. If you have received this transmission in error please notify the sender immediately. All email traffic sent to or from us, including without limitation all GCSX traffic, may be subject to recording and/or monitoring in accordance with relevant legislation.

config.yaml (26.3 KB)

···

The attached config.yaml works well for me and contains the legend element.
Note that I don’t use the GeoServer plugin but instead use the stand alone MapFish Print servelet - it’s considerably newer than the version used by the plugin so you may want to try that if you can’t resolve the issue.

Regards,
Jonathan

On 16 December 2013 05:44, Arunava Dey <thelastray@anonymised.com> wrote:

Hello,
I have already tried with iconMaxHeight and/or iconMaxWidth 0. But still getting the same result. This is my config file:

lastPage:
pageSize: A4
landscape: true
rotation: true
items:

  • !columns
    config:
    borderWidth: 1
    cells:
  • borderColor: black
    padding: 267
    absoluteX: 20
    absoluteY: 566
    width: 800
    height: 500
    items:
  • !text
    text: ‘’
    #Legend
  • !columns
    condition: legends
    absoluteX: 24
    absoluteY: 560
    width: 250
    config:
    borderWidth: 1
    cells:
  • borderWidth: 1
    borderColor: #555555
    padding: 5
    items:
  • !legends
    iconMaxWidth: 0
    iconMaxHeight: 0
    maxWidth: 250
    layerFont: Helvetica
    layerFontSize: 8
    classSpace: 2
    classIndentation: 5
    classFont: Helvetica
    classFontSize: 8
    backgroundColor: white
    inline:false

Thanking you,
Arunava Dey


Rapidly troubleshoot problems before they affect your business. Most IT
organizations don’t have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk


Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

On Fri, Dec 13, 2013 at 7:40 PM, Mauro Bartolomeoli <mauro.bartolomeoli@anonymised.com> wrote:

Hi Arunava,
try to change the iconMaxWidth and/or iconMaxHeight to 0 (zero) in your config.yaml, in the legend block.

Mauro

2013/12/13 Arunava Dey <thelastray@anonymised.com>

Hello,

I know this weird… Atlast got it to print the layer legend, but its too small to read. I am not getting what is going wrong. This what I am using:

{
“units”: “degrees”,
“srs”: “EPSG:4326”,
“layout”: “A4 Landscape”,
“dpi”: 150,
“mapTitle”: “MP GeoPortal Map”,
“comment”: “This map is printed using MP GeoPortal.”,
“resourcesUrl”: “http://localhost/mpgeoportal/img”,
“layers”: [
{
“baseURL”: “http://localhost:8080/geoserver/mpgeoportal/wms”,
“opacity”: 1,
“singleTile”: true,
“type”: “WMS”,
“layers”: [“mpgeoportal:sagar_geomorphology”],
“format”: “image/png”,
“styles”: [“”],
“customParams”: {
“TRANSPARENT”: true
}
}
],
“pages”: [{
“center”: [
78.800618943104,
23.871591352951
],
“scale”: 100000,
“rotation”: 0
}
],
“legends”: [
{
“name”: “Geomorphology”,
“classes”: [
{
“name” : “”,

“iconBeforeName”: true,
“icon”: “http%3A%2F%2Framtech-311%3A8080%2Fgeoserver%2Fmpgeoportal%2Fwms%3Fversion%3D1.3.0%26transpaparent%3Dtrue%26REQUEST%3DGetLegendGraphic%26EXCEPTIONS%3Dapplication%2Fvnd.ogc.se_xml%26ICON%3Dgeomorphology%26FORMAT%3Dimage%2Fpng%26MODE%3Dlegendicon%26layer%3Dmpgeoportal%3Asagar_geomorphology”
}
]
}
]
}

And this is what it is producing.
@Mauro Bartolomeoli My spec file is based on the following page https://github.com/mapfish/mapfish-print/issues/96. I am not very much sure about its contents. I have also checked with “icons” with square brackets. It is still giving the same result. Can you provide me a sample spec file with legend definition for geoserver.

Thanking you,

Arunava Dey

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


On Fri, Dec 13, 2013 at 1:39 PM, Mauro Bartolomeoli <mauro.bartolomeoli@anonymised.com> wrote:

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


2013/12/13 Arunava Dey <thelastray@anonymised.com>

Hello,

I am still struggling to print my map layer legends. Following is my spec file, encoded URL for icons as suggested by Mauro:

{
“units” : “degrees”,
“srs” : “EPSG:4326”,
“layout” : “A4 Landscape”,
“dpi” : 150,

“mapTitle” : “MP GeoPortal Map”,
“comment” : “This map is printed using MP GeoPortal.”,
“resourcesUrl” : “http://localhost/mpgeoportal/img”,
“layers” : [{
“baseURL” : “http://localhost:8080/geoserver/mpgeoportal/wms”,
“opacity” : 1,
“singleTile” : true,
“type” : “WMS”,
“layers” : [“mpgeoportal:sagar_geomorphology”],
“format” : “image/png”,
“styles” : [“”],
“customParams” : {
“TRANSPARENT” : true

}
}
],
“pages” : [{
“center” : [78.800618943104, 23.871591352951],
“scale” : 100000,
“rotation” : 0
}
],
“legends” : [{

“name” : “Geomorphology”,
“classes” : [{
“name” : “”,
“icons” : “http%3A%2F%2Flocalhost%3A8080%2Fgeoserver%2Fmpgeoportal%2Fwms%3Fversion%3D1.3.0%26TRANSPARENT%3DTRUE%26SERVICE%3DWMS%26REQUEST%3DGetLegendGraphic%26EXCEPTIONS%3Dapplication%2Fvnd.ogc.se_xml%26LAYER%3Dmpgeompgeoportal%3Asagar_geomorphology%26FORMAT%3Dimage%2Fpng”
}
]
}
]
}

I can see one more inconsistency: from the documentation examples (http://www.mapfish.org/doc/print/protocol.html#print-pdf) the “icons” property should be an array, so it should be written “icons”: [“…”].

I am having doubts about the name and icons block in legend definition. Is it for individual classes in my layer or it is for the entire layer? For example, for my geomorphology layer, I have, say 15 classes, namely g1, g2, g3 and so on. What should be the content for name block within classes. I am leaving it blank. Also the URL in icons gives the legend graphic for the entire layer (g1, g2…).

It depends on how you organize your layers/styles. From what I have seen, you have a single GetLegendGraphic call that is giving you back a set of icons (one for each Rule in the style) in a single image. In this use case you have one layer (Geomorphology) and only one class for the entire layer (rules are managed server side by GeoServer). This class has only one icon and no name (the rule names are also contained in the icons image).
Mapfish-print allows you also to build your legend client side, by having a layer with many classes, each with a label on a side (before or after the icons) and a set of icons, each with its url.

Regards,
Mauro Bartolomeoli

Hello,

I have tried with your sample file, but all in vain. I was wondering, how can I print only a single icon of any layer? I have passed the following json spec, hoping it will print only a single icon. Notice I have mentioned ICON=geomorphology%2C1. However it still prints the whole icon set, and consequently it is too small to read.

http://localhost:8080/geoserver/pdf/print.pdf?spec=
{
“units”: “degrees”,
“srs”: “EPSG:4326”,
“layout”: “A4 Landscape”,
“dpi”: 150,
“mapTitle”: “MP GeoPortal Map”,
“comment”: “This map is printed using MP GeoPortal.”,
“resourcesUrl”: “http://localhost/mpgeoportal/img”,
“layers”: [
{
“baseURL”: “http://localhost:8080/geoserver/mpgeoportal/wms”,
“opacity”: 1,
“singleTile”: true,
“type”: “WMS”,
“layers”: [“mpgeoportal:sagar_geomorphology”],
“format”: “image/png”,
“styles”: [“”],
“customParams”: {
“TRANSPARENT”: true
},
“legend”: true
}
],
“pages”: [{
“center”: [
78.800618943104,
23.871591352951
],
“scale”: 100000,
“rotation”: 0
}
],
“legends”: [
{
“name”: “Geomorphology”,
“classes”: [
{
“name” : “Bench”,
“iconBeforeName”: true,
“icon”: “http:///localhost:8080/geoserver/mpgeoportal/wms?version=1.1.1&transpaparent=true&REQUEST=GetLegendGraphic&EXCEPTIONS=application%2Fvnd.ogc.se_xml&ICON=geomorphology%2C1&FORMAT=image%2Fpng&MODE=legendicon”
}
]
}
]
}

Thanking you,

Arunava Dey

···

On Mon, Dec 16, 2013 at 4:59 PM, Jonathan Moules <jonathanmoules@anonymised.com> wrote:

Hi Arunava

This transmission is intended for the named addressee(s) only and may contain sensitive or protectively marked material up to RESTRICTED and should be handled accordingly. Unless you are the named addressee (or authorised to receive it for the addressee) you may not copy or use it, or disclose it to anyone else. If you have received this transmission in error please notify the sender immediately. All email traffic sent to or from us, including without limitation all GCSX traffic, may be subject to recording and/or monitoring in accordance with relevant legislation.

The attached config.yaml works well for me and contains the legend element.
Note that I don’t use the GeoServer plugin but instead use the stand alone MapFish Print servelet - it’s considerably newer than the version used by the plugin so you may want to try that if you can’t resolve the issue.

Regards,
Jonathan

On 16 December 2013 05:44, Arunava Dey <thelastray@anonymised.com> wrote:

Hello,
I have already tried with iconMaxHeight and/or iconMaxWidth 0. But still getting the same result. This is my config file:

lastPage:
pageSize: A4
landscape: true
rotation: true
items:

  • !columns
    config:
    borderWidth: 1
    cells:
  • borderColor: black
    padding: 267
    absoluteX: 20
    absoluteY: 566
    width: 800
    height: 500
    items:
  • !text
    text: ‘’
    #Legend
  • !columns
    condition: legends
    absoluteX: 24
    absoluteY: 560
    width: 250
    config:
    borderWidth: 1
    cells:
  • borderWidth: 1
    borderColor: #555555
    padding: 5
    items:
  • !legends
    iconMaxWidth: 0
    iconMaxHeight: 0
    maxWidth: 250
    layerFont: Helvetica
    layerFontSize: 8
    classSpace: 2
    classIndentation: 5
    classFont: Helvetica
    classFontSize: 8
    backgroundColor: white
    inline:false

Thanking you,
Arunava Dey


Rapidly troubleshoot problems before they affect your business. Most IT
organizations don’t have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk


Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

On Fri, Dec 13, 2013 at 7:40 PM, Mauro Bartolomeoli <mauro.bartolomeoli@anonymised.com> wrote:

Hi Arunava,
try to change the iconMaxWidth and/or iconMaxHeight to 0 (zero) in your config.yaml, in the legend block.

Mauro

2013/12/13 Arunava Dey <thelastray@anonymised.com>

Hello,

I know this weird… Atlast got it to print the layer legend, but its too small to read. I am not getting what is going wrong. This what I am using:

{
“units”: “degrees”,
“srs”: “EPSG:4326”,
“layout”: “A4 Landscape”,
“dpi”: 150,
“mapTitle”: “MP GeoPortal Map”,
“comment”: “This map is printed using MP GeoPortal.”,
“resourcesUrl”: “http://localhost/mpgeoportal/img”,
“layers”: [
{
“baseURL”: “http://localhost:8080/geoserver/mpgeoportal/wms”,
“opacity”: 1,
“singleTile”: true,
“type”: “WMS”,
“layers”: [“mpgeoportal:sagar_geomorphology”],
“format”: “image/png”,
“styles”: [“”],
“customParams”: {
“TRANSPARENT”: true
}
}
],
“pages”: [{
“center”: [
78.800618943104,
23.871591352951
],
“scale”: 100000,
“rotation”: 0
}
],
“legends”: [
{
“name”: “Geomorphology”,
“classes”: [
{
“name” : “”,

“iconBeforeName”: true,
“icon”: “http%3A%2F%2Framtech-311%3A8080%2Fgeoserver%2Fmpgeoportal%2Fwms%3Fversion%3D1.3.0%26transpaparent%3Dtrue%26REQUEST%3DGetLegendGraphic%26EXCEPTIONS%3Dapplication%2Fvnd.ogc.se_xml%26ICON%3Dgeomorphology%26FORMAT%3Dimage%2Fpng%26MODE%3Dlegendicon%26layer%3Dmpgeoportal%3Asagar_geomorphology”
}
]
}
]
}

And this is what it is producing.
@Mauro Bartolomeoli My spec file is based on the following page https://github.com/mapfish/mapfish-print/issues/96. I am not very much sure about its contents. I have also checked with “icons” with square brackets. It is still giving the same result. Can you provide me a sample spec file with legend definition for geoserver.

Thanking you,

Arunava Dey

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


On Fri, Dec 13, 2013 at 1:39 PM, Mauro Bartolomeoli <mauro.bartolomeoli@anonymised.com> wrote:

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


2013/12/13 Arunava Dey <thelastray@anonymised.com>

Hello,

I am still struggling to print my map layer legends. Following is my spec file, encoded URL for icons as suggested by Mauro:

{
“units” : “degrees”,
“srs” : “EPSG:4326”,
“layout” : “A4 Landscape”,
“dpi” : 150,

“mapTitle” : “MP GeoPortal Map”,
“comment” : “This map is printed using MP GeoPortal.”,
“resourcesUrl” : “http://localhost/mpgeoportal/img”,
“layers” : [{
“baseURL” : “http://localhost:8080/geoserver/mpgeoportal/wms”,
“opacity” : 1,
“singleTile” : true,
“type” : “WMS”,
“layers” : [“mpgeoportal:sagar_geomorphology”],
“format” : “image/png”,
“styles” : [“”],
“customParams” : {
“TRANSPARENT” : true

}
}
],
“pages” : [{
“center” : [78.800618943104, 23.871591352951],
“scale” : 100000,
“rotation” : 0
}
],
“legends” : [{

“name” : “Geomorphology”,
“classes” : [{
“name” : “”,
“icons” : “http%3A%2F%2Flocalhost%3A8080%2Fgeoserver%2Fmpgeoportal%2Fwms%3Fversion%3D1.3.0%26TRANSPARENT%3DTRUE%26SERVICE%3DWMS%26REQUEST%3DGetLegendGraphic%26EXCEPTIONS%3Dapplication%2Fvnd.ogc.se_xml%26LAYER%3Dmpgeompgeoportal%3Asagar_geomorphology%26FORMAT%3Dimage%2Fpng”
}
]
}
]
}

I can see one more inconsistency: from the documentation examples (http://www.mapfish.org/doc/print/protocol.html#print-pdf) the “icons” property should be an array, so it should be written “icons”: [“…”].

I am having doubts about the name and icons block in legend definition. Is it for individual classes in my layer or it is for the entire layer? For example, for my geomorphology layer, I have, say 15 classes, namely g1, g2, g3 and so on. What should be the content for name block within classes. I am leaving it blank. Also the URL in icons gives the legend graphic for the entire layer (g1, g2…).

It depends on how you organize your layers/styles. From what I have seen, you have a single GetLegendGraphic call that is giving you back a set of icons (one for each Rule in the style) in a single image. In this use case you have one layer (Geomorphology) and only one class for the entire layer (rules are managed server side by GeoServer). This class has only one icon and no name (the rule names are also contained in the icons image).
Mapfish-print allows you also to build your legend client side, by having a layer with many classes, each with a label on a side (before or after the icons) and a set of icons, each with its url.

Regards,
Mauro Bartolomeoli

Hi,
I might have missed a bit of this thread, but what are you aiming for? Do you just want a legend? Or a legend that only contains a single icon?
I had the legend-getting-shrunk-too-small problem, but fixed it by increasing my icon sizes in the config I sent. As such I now get readable legends in my maps (up to about 10 items, then they start getting shrunk again). If you don’t, even with my config, I’d suggest trying a newer version of MFP.

Regards,
Jonathan

This transmission is intended for the named addressee(s) only and may contain sensitive or protectively marked material up to RESTRICTED and should be handled accordingly. Unless you are the named addressee (or authorised to receive it for the addressee) you may not copy or use it, or disclose it to anyone else. If you have received this transmission in error please notify the sender immediately. All email traffic sent to or from us, including without limitation all GCSX traffic, may be subject to recording and/or monitoring in accordance with relevant legislation.

···

On 16 December 2013 13:26, Arunava Dey <thelastray@anonymised.com> wrote:

Hello,

I have tried with your sample file, but all in vain. I was wondering, how can I print only a single icon of any layer? I have passed the following json spec, hoping it will print only a single icon. Notice I have mentioned ICON=geomorphology%2C1. However it still prints the whole icon set, and consequently it is too small to read.

http://localhost:8080/geoserver/pdf/print.pdf?spec=

{
“units”: “degrees”,
“srs”: “EPSG:4326”,
“layout”: “A4 Landscape”,
“dpi”: 150,
“mapTitle”: “MP GeoPortal Map”,
“comment”: “This map is printed using MP GeoPortal.”,
“resourcesUrl”: “http://localhost/mpgeoportal/img”,
“layers”: [
{
“baseURL”: “http://localhost:8080/geoserver/mpgeoportal/wms”,
“opacity”: 1,
“singleTile”: true,
“type”: “WMS”,
“layers”: [“mpgeoportal:sagar_geomorphology”],
“format”: “image/png”,
“styles”: [“”],
“customParams”: {
“TRANSPARENT”: true
},

“legend”: true

}
],
“pages”: [{
“center”: [
78.800618943104,
23.871591352951
],
“scale”: 100000,
“rotation”: 0
}
],
“legends”: [
{
“name”: “Geomorphology”,
“classes”: [
{

“name” : “Bench”,
“iconBeforeName”: true,
“icon”: “http:///localhost:8080/geoserver/mpgeoportal/wms?version=1.1.1&transpaparent=true&REQUEST=GetLegendGraphic&EXCEPTIONS=application%2Fvnd.ogc.se_xml&ICON=geomorphology%2C1&FORMAT=image%2Fpng&MODE=legendicon”
}
]
}
]
}

Thanking you,

Arunava Dey

On Mon, Dec 16, 2013 at 4:59 PM, Jonathan Moules <jonathanmoules@anonymised.com> wrote:

Hi Arunava

This transmission is intended for the named addressee(s) only and may contain sensitive or protectively marked material up to RESTRICTED and should be handled accordingly. Unless you are the named addressee (or authorised to receive it for the addressee) you may not copy or use it, or disclose it to anyone else. If you have received this transmission in error please notify the sender immediately. All email traffic sent to or from us, including without limitation all GCSX traffic, may be subject to recording and/or monitoring in accordance with relevant legislation.

The attached config.yaml works well for me and contains the legend element.
Note that I don’t use the GeoServer plugin but instead use the stand alone MapFish Print servelet - it’s considerably newer than the version used by the plugin so you may want to try that if you can’t resolve the issue.

Regards,
Jonathan

On 16 December 2013 05:44, Arunava Dey <thelastray@anonymised.com> wrote:

Hello,
I have already tried with iconMaxHeight and/or iconMaxWidth 0. But still getting the same result. This is my config file:

lastPage:
pageSize: A4
landscape: true
rotation: true
items:

  • !columns
    config:
    borderWidth: 1
    cells:
  • borderColor: black
    padding: 267
    absoluteX: 20
    absoluteY: 566
    width: 800
    height: 500
    items:
  • !text
    text: ‘’
    #Legend
  • !columns
    condition: legends
    absoluteX: 24
    absoluteY: 560
    width: 250
    config:
    borderWidth: 1
    cells:
  • borderWidth: 1
    borderColor: #555555
    padding: 5
    items:
  • !legends
    iconMaxWidth: 0
    iconMaxHeight: 0
    maxWidth: 250
    layerFont: Helvetica
    layerFontSize: 8
    classSpace: 2
    classIndentation: 5
    classFont: Helvetica
    classFontSize: 8
    backgroundColor: white
    inline:false

Thanking you,
Arunava Dey


Rapidly troubleshoot problems before they affect your business. Most IT
organizations don’t have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk


Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

On Fri, Dec 13, 2013 at 7:40 PM, Mauro Bartolomeoli <mauro.bartolomeoli@anonymised.com> wrote:

Hi Arunava,
try to change the iconMaxWidth and/or iconMaxHeight to 0 (zero) in your config.yaml, in the legend block.

Mauro

2013/12/13 Arunava Dey <thelastray@anonymised.com>

Hello,

I know this weird… Atlast got it to print the layer legend, but its too small to read. I am not getting what is going wrong. This what I am using:

{
“units”: “degrees”,
“srs”: “EPSG:4326”,
“layout”: “A4 Landscape”,
“dpi”: 150,
“mapTitle”: “MP GeoPortal Map”,
“comment”: “This map is printed using MP GeoPortal.”,
“resourcesUrl”: “http://localhost/mpgeoportal/img”,
“layers”: [
{
“baseURL”: “http://localhost:8080/geoserver/mpgeoportal/wms”,
“opacity”: 1,
“singleTile”: true,
“type”: “WMS”,
“layers”: [“mpgeoportal:sagar_geomorphology”],
“format”: “image/png”,
“styles”: [“”],
“customParams”: {
“TRANSPARENT”: true
}
}
],
“pages”: [{
“center”: [
78.800618943104,
23.871591352951
],
“scale”: 100000,
“rotation”: 0
}
],
“legends”: [
{
“name”: “Geomorphology”,
“classes”: [
{
“name” : “”,

“iconBeforeName”: true,
“icon”: “http%3A%2F%2Framtech-311%3A8080%2Fgeoserver%2Fmpgeoportal%2Fwms%3Fversion%3D1.3.0%26transpaparent%3Dtrue%26REQUEST%3DGetLegendGraphic%26EXCEPTIONS%3Dapplication%2Fvnd.ogc.se_xml%26ICON%3Dgeomorphology%26FORMAT%3Dimage%2Fpng%26MODE%3Dlegendicon%26layer%3Dmpgeoportal%3Asagar_geomorphology”
}
]
}
]
}

And this is what it is producing.
@Mauro Bartolomeoli My spec file is based on the following page https://github.com/mapfish/mapfish-print/issues/96. I am not very much sure about its contents. I have also checked with “icons” with square brackets. It is still giving the same result. Can you provide me a sample spec file with legend definition for geoserver.

Thanking you,

Arunava Dey

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


On Fri, Dec 13, 2013 at 1:39 PM, Mauro Bartolomeoli <mauro.bartolomeoli@anonymised.com> wrote:

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


2013/12/13 Arunava Dey <thelastray@anonymised.com>

Hello,

I am still struggling to print my map layer legends. Following is my spec file, encoded URL for icons as suggested by Mauro:

{
“units” : “degrees”,
“srs” : “EPSG:4326”,
“layout” : “A4 Landscape”,
“dpi” : 150,

“mapTitle” : “MP GeoPortal Map”,
“comment” : “This map is printed using MP GeoPortal.”,
“resourcesUrl” : “http://localhost/mpgeoportal/img”,
“layers” : [{
“baseURL” : “http://localhost:8080/geoserver/mpgeoportal/wms”,
“opacity” : 1,
“singleTile” : true,
“type” : “WMS”,
“layers” : [“mpgeoportal:sagar_geomorphology”],
“format” : “image/png”,
“styles” : [“”],
“customParams” : {
“TRANSPARENT” : true

}
}
],
“pages” : [{
“center” : [78.800618943104, 23.871591352951],
“scale” : 100000,
“rotation” : 0
}
],
“legends” : [{

“name” : “Geomorphology”,
“classes” : [{
“name” : “”,
“icons” : “http%3A%2F%2Flocalhost%3A8080%2Fgeoserver%2Fmpgeoportal%2Fwms%3Fversion%3D1.3.0%26TRANSPARENT%3DTRUE%26SERVICE%3DWMS%26REQUEST%3DGetLegendGraphic%26EXCEPTIONS%3Dapplication%2Fvnd.ogc.se_xml%26LAYER%3Dmpgeompgeoportal%3Asagar_geomorphology%26FORMAT%3Dimage%2Fpng”
}
]
}
]
}

I can see one more inconsistency: from the documentation examples (http://www.mapfish.org/doc/print/protocol.html#print-pdf) the “icons” property should be an array, so it should be written “icons”: [“…”].

I am having doubts about the name and icons block in legend definition. Is it for individual classes in my layer or it is for the entire layer? For example, for my geomorphology layer, I have, say 15 classes, namely g1, g2, g3 and so on. What should be the content for name block within classes. I am leaving it blank. Also the URL in icons gives the legend graphic for the entire layer (g1, g2…).

It depends on how you organize your layers/styles. From what I have seen, you have a single GetLegendGraphic call that is giving you back a set of icons (one for each Rule in the style) in a single image. In this use case you have one layer (Geomorphology) and only one class for the entire layer (rules are managed server side by GeoServer). This class has only one icon and no name (the rule names are also contained in the icons image).
Mapfish-print allows you also to build your legend client side, by having a layer with many classes, each with a label on a side (before or after the icons) and a set of icons, each with its url.

Regards,
Mauro Bartolomeoli