Printing 如何为GeoServer GeoWebCache层使用MapFish打印模块?

Printing 如何为GeoServer GeoWebCache层使用MapFish打印模块?,printing,openlayers,geoserver,Printing,Openlayers,Geoserver,我正在使用GeoServer(2.1.1)、GeoWebCache(1.2.6)、OpenLayers(2.11)、GeoExt开发webGIS应用程序。我的所有层都通过GeoWebCache作为wms。任何图层的示例定义如下所示: var My_Layer = new OpenLayers.Layer.WMS( "My_Layer", "http://my-ip + my-port/geoserver/gwc/service/wms", {la

我正在使用GeoServer(2.1.1)、GeoWebCache(1.2.6)、OpenLayers(2.11)、GeoExt开发webGIS应用程序。我的所有层都通过GeoWebCache作为wms。任何图层的示例定义如下所示:

 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} );
到目前为止,一切都很顺利。但是,当我计划向前推进一点并尝试实现MapFish打印模块时。。。。。。输出pdf为空!!!我收到以下错误消息:

java.io.IOException:读取图像时出错(状态=400) 从

我找了很多。根据一个选项是访问我的层作为TMS层。但我不想要静态图像层,而不是GeoServer WMS地图层

另一个选项是使用OpenLayers.Control.ExportMap()。 但这限制了使用不同的尺度,因为我的数据范围太大了。因此,如果用户希望打印整个地图区域(可能在A0纸上),而该区域在Openlayers div中不完全可见,则在特定比例下无法解决此问题

所以问题是,我如何在不使用TMS或GeoWebCache层的情况下实现这一点

编辑#1: 对不起,我迟到了,因为我不在办公室。下面是我的config.yaml文件。我觉得没有错误,这可以直接从GeoServer打印我的WMS图层

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

如果不进行进一步调试,400错误就太模糊,无法提供太多帮助。根据经验,我可以告诉您,我以前见过一个问题,geowebcache服务器不喜欢为您请求的wms层提供服务。Mapfish试图用不同的瓷砖大小做一些奇怪的事情(最终会得到10%的阈值错误)。您的日志是否显示它请求的图像?你能到我们浏览器中的那个互动程序去看看服务器到底说了些什么吗?这就是我最终暴露我的问题的方式

为了便于调试,我还创建了一个单独的mapfish日志,以便于查找我的mapfish问题。使用Geoserver管理屏幕确定您正在使用的日志配置文件,然后在log4j.properties文件中,为mapfish添加单独的文件附加器,并将所有org.mapfish活动指向该文件。这使得调试更加容易

最后,我个人的建议是:在你的config.yaml中,不要使用输出格式:[pdf], 相反,请使用格式:['pdf']


尽管所有文档都描述outputFormat(这是客户机“规范”中所要求的),但实际的服务器配置使用“formats”变量。我已经提交了一个补丁,以便在文档中更清楚地说明这一点,但在此之前,让我们将此注释作为指南。如果要进入图像输出,这是关键。

mapfish配置正确吗?你能发布config.yaml吗?