Class: Print

ngeo.Print

new Print(url, $http, ngeoLayerHelper)

Provides a function to create ngeo.Print objects used to interact with MapFish Print v3 services.

ngeo.Print objects expose the following methods:

  • createSpec: create a report specification object
  • createReport: send a create report request
  • getStatus: get the status of a report
  • getReportUrl: get the URL of a report
  • getCapabilities: get the capabilities of the server
let printBaseUrl = 'http://example.com/print';
let print = new ngeo.Print(printBaseUrl);

let scale = 5000;
let dpi = 72;
let layout = 'A4 portrait';
let format = 'pdf';
let reportSpec = print.createSpec(map, scale, dpi, layout, format, {
  'title': 'A title for my report',
  'rotation': 45 // degree
});

See our live example: ../examples/mapfishprint.html

TODO and limitations:

  • createSpec should also accept a bbox instead of a center and a scale.
  • Add support for ol.style.RegularShape. MapFish Print supports symbols like crosses, stars and squares, so printing regular shapes should be possible.
  • ol.style.Icon may use a sprite image, and offsets to define to rectangle to use within the sprite. This type of icons won't be printed correctly as MapFish Print does not support sprite icons.
Parameters:
Name Type Description
url string

URL to MapFish print web service.

$http angular.$http

Angular $http service.

ngeoLayerHelper ngeo.LayerHelper

Ngeo Layer Helper service.

Methods

cancel(ref, [opt_httpConfig]opt)

Cancel a report.

Parameters:
Name Type Attributes Description
ref string

Print report reference.

[opt_httpConfig] angular.$http.Config= <optional>

$http config object.

Returns:

createReport(printSpec, [opt_httpConfig]opt)

Send a create report request to the MapFish Print service.

Parameters:
Name Type Attributes Description
printSpec MapFishPrintSpec

Print specification.

[opt_httpConfig] angular.$http.Config= <optional>

$http config object.

Returns:

createSpec(map, scale, dpi, layout, format, customAttributes)

Create a report specification.

Parameters:
Name Type Description
map ol.Map

Map.

scale number

Scale.

dpi number

DPI.

layout string

Layout.

format string

Formats.

customAttributes Object.

Custom attributes.

Returns:
MapFishPrintSpec

The print spec.

encodeLayer(arr, layer, resolution)

Parameters:
Name Type Description
arr Array.

Array.

layer ol.layer.Base

Layer.

resolution number

Resolution.

getCapabilities([opt_httpConfig]opt)

Get the print capabilities from MapFish Print.

Parameters:
Name Type Attributes Description
[opt_httpConfig] angular.$http.Config= <optional>

$http config object.

Returns:

getReportUrl(ref)

Get the URL of a report.

Parameters:
Name Type Description
ref string

Print report reference.

Returns:
string

The report URL for this ref.

getStatus(ref, [opt_httpConfig]opt)

Get the status of a report.

Parameters:
Name Type Attributes Description
ref string

Print report reference.

[opt_httpConfig] angular.$http.Config= <optional>

$http config object.

Returns: