3
votes

I am in the process of developing a webGIS application using GeoServer (2.1.1), GeoWebCache(1.2.6), OpenLayers(2.11), GeoExt. All my layers are served as wms through GeoWebCache. A sample definition for any layer is as follows:

 var My_Layer = new OpenLayers.Layer.WMS( "My_Layer",
            "http://my-ip + my-port/geoserver/gwc/service/wms",
            {layers: 'layer-name',transparent: "true",format: "image/png",
             tileSize: new OpenLayers.Size(256,256),
             tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom },
            { isBaseLayer: false, visibility:false} );

Everything was working fine, till this point. But, when I planned to move a bit ahead and tried implementing MapFish Printing module...... the output pdf is blank!!! I am getting the following error message:

java.io.IOException: Error (status=400) while reading the image from........

I have searched a lot. According to this one option is to access my layers as TMS layer. But I don't want a static image layer, instead of a GeoServer WMS map layer.

Again another option found here is using OpenLayers.Control.ExportMap(). But that restricts using different scales, since my data extent is too big . As a result at a specific scale if user wants to take a print of the entire map area(may be in an A0 paper), which is not visible fully in the Openlayers div, this can not solve the purpose.

So the question is how can I accomplish this, without using a TMS or GeoWebCache layer?

Edit # 1 : Sorry I am late, as I was out of office. Following is my config.yaml file. I feel there is no error, this can print my WMS layers, coming directly from GeoServer.

dpis: [75, 150, 300]

outputFormats:
  - pdf

scales:
  - 10000
  - 25000
  - 50000
  - 100000

hosts:
  - !localMatch
    dummy: true
  - !ipMatch
    ip: www.camptocamp.org
  - !dnsMatch
    host: labs.metacarta.com
    port: 80
  - !dnsMatch
    host: terraservice.net
    port: 80
  - !dnsMatch
    host: sigma.openplans.org
  - !dnsMatch
    host: demo.mapfish.org

layouts:
  A4 portrait:
    metaData:
      title: 'Arunava TopoMap PDF'
      author: 'Arunava print module'
      subject: 'Map layout'
      keywords: 'map,print'
      creator: 'Arunava'
    mainPage:
      pageSize: A4
      rotation: true
      items:
        - !text
          text: '${mapTitle}  ${now MM.dd.yyyy}'
          fontSize: 20
          spacingAfter: 30
        - !map
          spacingAfter: 30
          width: 440
          height: 600
        - !scalebar
          type: bar
          maxSize: 100
          barBgColor: white
          fontSize: 8
          align: right
        - !text
          font: Helvetica
          fontSize: 9
          align: right
          text: '1:${scale}'
      footer: *commonFooter

  A2 portrait:
    metaData:
      title: 'Arunava TopoMap PDF'
      author: 'Arunava print module'
      subject: 'Map layout'
      keywords: 'map,print'
      creator: 'Arunava'
    mainPage:
      pageSize: A2
      rotation: true
      items:
        - !text
          text: '${mapTitle}  ${now MM.dd.yyyy}'
          fontSize: 20
          spacingAfter: 30
        - !map
          spacingAfter: 30
          width: 880
          height: 1200
        - !scalebar
          type: bar
          maxSize: 100
          barBgColor: white
          fontSize: 8
          align: right
        - !text
          font: Helvetica
          fontSize: 9
          align: right
          text: '1:${scale}'
      footer: *commonFooter
1
is mapfish configure correctly? can you post config.yaml?igorti

1 Answers

2
votes

Without further debugging, the 400 error is too vague for much help. From experience, I can tell you I've seen an issue before where the geowebcache server doesn't like serving the wms layer you are requesting. Mapfish tries to do weird things with different tile sizes (and you eventually get a 10% threshold error). Does your log show the image it was requesting? Can you go to that tile in our browser to see what the server actually says? This is how I eventually exposed my issues.

For easier debugging, I've also created a seperate mapfish log to make it easier to find my mapfish issues. Use the Geoserver admin screen to figure out which logging profile you are using, then in that log4j.properties file, add a seperate file appender for mapfish, and direct all org.mapfish activity to it. This makes debugging much easier.

And FINALLY, my own personal crusade: in your config.yaml, don't use outputFormats: [pdf], instead, use formats: ['pdf'].

Even though all the docs describe outputFormat (and that's what required in the client "spec"), the actual server config is uses the 'formats' variable. I've submitted a patch to make this more clear in the docs, but until then, let's this note be a guide. If you want to get into the image output, this is key.