mapfish.PrintProtocol

Class to communicate with the print module.

This class will automatically pick the layers from the OL map and create the configuration structure accordingly.

As we often want a sligtly different styling or minScale/maxScale, an override functionallity is provided that allows to override the OL layers’ configuration, this can be used as well if a layer’s URL points to a TileCache service to allow the print module to access the WMS service directly.

An override structure may look like this

{
  'layerName1': { visibility: false },
  'layerName2': {
    visibility: false,
    300: { visibility: true }
  }
}

In this example, the OL layer named “layerName1” is never printed.  The OL layer “layerName2” is visible only when printed at 300DPI.

Summary
mapfish.PrintProtocolClass to communicate with the print module.
Properties
config{String} the configuration as returned by the MapPrinterServlet.
spec{Object} The complete spec to send to the servlet.
params{Object} Additional params to send in the print service Ajax calls.
geodetic{Boolean} True if the projection is geodetic, for a correct scale calculation.
Constructor
OpenLayers.Layer
Functions
getAllInOneUrlCreates the URL string for generating a PDF using the print module.
createPDFUses AJAX to create the PDF on the server and then gets it from the server.
getConfigurationDoes an AJAX call to get the print configuration from the server.

Properties

config

{String} the configuration as returned by the MapPrinterServlet.

spec

{Object} The complete spec to send to the servlet.  You can use it to add custom parameters.

params

{Object} Additional params to send in the print service Ajax calls.  Can be used to set the “locale” parameter.

geodetic

{Boolean} True if the projection is geodetic, for a correct scale calculation.

Constructor

OpenLayers.Layer

Parameters

map{OpenLayers.Map} The OL MAP.
config{Object} the configuration as returned by the MapPrinterServlet.
overrides{Object} the map that specify the print module overrides for each layers.
dpi{Integer} the DPI resolution
params{Object} additional params to send in the Ajax calls

Functions

getAllInOneUrl

getAllInOneUrl: function()

Creates the URL string for generating a PDF using the print module.  Using the direct method.

WARNING: this method has problems with accents and requests with lots of pages.  But it has the advantage to work without proxy.

Returns

{String} The URL

createPDF

createPDF: function(success,
popup,
failure,
context)

Uses AJAX to create the PDF on the server and then gets it from the server.  If it doesn’t work (different URL and OpenLayers.ProxyHost not set), try the GET direct method.

Parameters

success{Function} The function to call in case of success.
popup{Function} The function to call in case of success, but when unable to load automatically the document.
failure{Function} The function to call in case of failure.  Gets the request object in parameter.  If getURL is defined, the popup where blocked and the PDF can still be recovered using this URL.
context{Object} The context to use to call the success of failure method.

getConfiguration

mapfish.PrintProtocol.getConfiguration = function(url,
success,
failure,
context,
params)

Does an AJAX call to get the print configuration from the server.

Parameters

url{String} the URL to access .../config.json
success{Function} the function that will be called with the configuration object when/if its received.
failure{Function} the function that is called in case of error.
context{Object} The context to use when calling the callbacks.
params{Object} additional params to send in the Ajax calls
getAllInOneUrl: function()
Creates the URL string for generating a PDF using the print module.
createPDF: function(success,
popup,
failure,
context)
Uses AJAX to create the PDF on the server and then gets it from the server.
mapfish.PrintProtocol.getConfiguration = function(url,
success,
failure,
context,
params)
Does an AJAX call to get the print configuration from the server.
Instances of OpenLayers.Map are interactive maps embedded in a web page.
Close