[GIS] How to use different config.yaml files for application using mapfish print in geoserver

mapfishprinting

System: Ubuntu 10.04 server / Tomcat6 / geoserver2.1.2 with integrated GeoWebCache

I have various webmapping applications running which utilize the mapfish print module.Some are in tomcat6/webapps some are in my apache2 DocRoot. I need to have various mapfish print layouts to show different logos, legends, scalebars etc depending on which webmapping application is using it….but I only have one config.yaml file to style the pdf layout.

Qustion: How can Have I various versions of config.yaml and link them to the different webapps?

I´d be grateful for any replies,

yours,

Rob

Best Answer

Normally it shouldn't be necessary to have multiple configuration files for the mapfish print module because you can make multiple layouts in your config file (with optional parameters) which you then post to the pdf/create.json URL. This page has some info (although it's a little outdated): http://www.mapfish.org/doc/print/configuration.html. In essence you can just add multiple layout descriptions like this:

layouts:
   {LAYOUT_NAME}:
?   : Mapfish-print.pdf  MF_V1.2
?   metaData:
?     {METADATA_DEFINITION}
?   titlePage:
?     {PAGE_DEFINITION}
    mainPage:
?     rotation: false
      {PAGE_DEFINITION}
?   lastPage:
?     {PAGE_DEFINITION}
  {...}

(note: use ! in front of a parameter to make it optional)

The only way to have multiple configurations (that I know of) is to have multiple print links which all use a separate config. You can do that by editing the /usr/lib/apache-tomcat/webapps/print/WEB-INF/web.xml file and add more servlets:

    <servlet>
    <servlet-name>mapfish.print2</servlet-name>
    <servlet-class>org.mapfish.print.servlet.MapPrinterServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>your_2nd_config_here.yaml</param-value>
    </init-param>
  </servlet>
  <servlet-mapping>
    <servlet-name>mapfish.print2</servlet-name>
    <url-pattern>/pdf_nameoftheurl/*</url-pattern>
  </servlet-mapping>

  <servlet>
    <servlet-name>mapfish.print3</servlet-name>
    <servlet-class>org.mapfish.print.servlet.MapPrinterServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>your_3rd_config_here.yaml</param-value>
    </init-param>
  </servlet>
  <servlet-mapping>
    <servlet-name>mapfish.print3</servlet-name>
    <url-pattern>/pdf_anotherurlname/*</url-pattern>
  </servlet-mapping>

I hope this gives you enough information to get it working!

Related Question