cgxp.plugins.Print

ptype
cgxp_print
class cgxp.plugins.Print(config)

Example Use

Sample code showing how to add a Print plugin to a gxp.Viewer in a existing container:

<% from json import dumps %>
new gxp.Viewer({
    ...
    tools: [{
        ptype: 'cgxp_print',
        legendPanelId: "legendPanel",
        featureProvider: "featuresProvider",
        outputTarget: "left-panel",
        printURL: "${request.route_url('printproxy')}",
        mapserverURL: "${request.route_url('mapserverproxy')}",
        printProviderConfig: ${dumps(version_role_params)|n},
        options: {
            labelAlign: 'top',
            defaults: {
                anchor: '100%'
            },
            autoFit: true
        }
    }]
    ...
});

Sample code showing how to add a Print plugin to a gxp.Viewer via an icon in a toolbar. The print form will show up in a CGXP.tool.Window below the toolbar:

<% from json import dumps %>
new gxp.Viewer({
    ...
    tools: [{
        ptype: 'cgxp_print',
        legendPanelId: "legendPanel",
        featureProvider: "featuresProvider",
        actionTarget: "center.tbar",
        toggleGroup: "maptools",
        printURL: "${request.route_url('printproxy')}",
        mapserverURL: "${request.route_url('mapserverproxy')}",
        printProviderConfig: ${dumps(version_role_params)|n},
        options: {
            labelAlign: 'top',
            defaults: {
                anchor: '100%'
            },
            autoFit: true
        }
    }]
    ...
});

Sample code using the MapFishPrint version 3:

new gxp.Viewer({
    ...
    tools: [{
        ptype: 'cgxp_print',
        legendPanelId: "legendPanel",
        featureProvider: "featureGrid",
        actionTarget: "center.tbar",
        toggleGroup: "maptools",
        printURL: "${request.route_url("printproxy", path="")}",
        mapserverURL: "${request.route_url("mapserverproxy", path="")}",
        options: {
            labelAlign: 'top',
            defaults: {
                anchor: '100%'
            },
            autoFit: true
        },
        version: 3
    }]
    ...
});

Config Options

Configuration properties.

actionTarget

Object or String or Array Where to place the tool’s actions (e.g. buttons or menus)? As opposed to CGXP.plugins.Tool, we don’t want it to be set by default to the mapPanel top toolbar.

activateToggleGroup

String The name of the activate toggle group this tool is in. Default is “clickgroup”.

additionalAttributes

Array Attributes added in the print form used especially with print V2.

Default for version 2:

[{
    name: "title",
    label: OpenLayers.i18n("Title"),
    type: "String"
}, {
    name: "comment",
    label: OpenLayers.i18n("Comment"),
    type: "String",
    useTextArea: true
}, {
    name: "legend",
    type: "LegendAttributeValue"
}]

For version 3: []

borderStyle

Object Style config of the print extent stroke.

checkLegend

Boolean Initial activation status of the legend (default is true).

encodeExternalLayer

Object Additional attribute used to encode external layer. Default for version 2: { useNativeAngle: true } for version 3: { useNativeAngle: true, serverType: ‘mapserver’ }

encodeLayer

Object Additional attribute used to encode internal layer. Default for version 2: { useNativeAngle: true } for version 3: { useNativeAngle: true, serverType: ‘mapserver’ }

extentStyle

Object Style config of the print extent fill.

featureProvider

String Id of the featureProvider tool.

legendPanelId

String Id of the legendPanel tool.

mapserverURL

String URL of the mapserver proxy.

options

Object The options given to the print panel. E.g.:

options: {
    labelAlign: "top",
    defaults: {
        anchor: "100%"
    },
    autoFit: true,
    fieldsExtraClientConfiguration: {
        "A4_portrait": {
            "title": {
                fieldAttributes: {
                    fieldLabel: "${_("Name")}",
                    emptyText: "${_("Name")}"
                }
            },
            "description": {
                useTextArea: true,
                fieldAttributes: {
                    fieldLabel: "${_("Description")}",
                    emptyText: "${_("Description")}",
                    autoCreate: {maxLength: 200}
                }
            },
            "debug": {
                ignore: true
            }
        }
    }
}

Default to: {}.

printProviderConfig

Object Optional parameters to send to the print proxy.

printURL

String URL of the print proxy.

rotateStyle

Object Style config of the rotate icon.

timeout

Number The timeout delay for the print in milliseconds. Default to 2 minutes.

version

Number The print major version, Default is 2.

Public Properties

Public properties.

Print.paramRenderer

Object<String, Function> Map of function used to renderer a parameter

Table Of Contents

Previous topic

cgxp.plugins.Permalink

Next topic

cgxp.plugins.Profile

This Page

Fork me on GitHub