The Web Printing Service turns on asynchronous printing mode by default. To create a print job:

  1. Access the iServer service list and select the webprinting/rest service resource
  2. Click webprinting-> v1-> jobs to enter the print task list resource page.
  3. Click Create Print Task to enter the Create Print Task Resource pack
  4. Enter the POST request body and click the "Create Print Task" button to start executing the task. For information about how to write a request body, see That prints the task list resource POST request .

The request body for creating print job input consists of three top-level objects:

{

    "content": {},

    "layoutOptions": {},

    "exportOptions": {}

}

content

The Content object is a required object that defines the Web content to be printed. Consists of the following parameters:

Example 1: Incoming a SuperMap iPortal data above the WebMap made by the Web App The url address

{

    "content": {

        "type": "WEBMAP",

        "url":"http://supermapiportal:8190/iportal/web/maps/{mapid}/map.rjson"

     }

}

Example 2: Pass in the json of a complete SuperMap iPortal data and the WebMap made on the map Expression

{

    "content": {

        "type": "WEBMAP",

        "value": {

            "extent": {

                "leftBottom": {

                    "x": -20037508.3427892,

                    "y": -20037508.3427891

                },

                "rightTop": {

                    "x": 20037508.3427892,

                    "y": 20037508.3427891

                }

            },

            "maxScale": "1:144447.927",

            "level": 4,

            "center": {

                "x": 11382417.9336122,

                "y": 4134167.44525748

            },

            "baseLayer": {

                "layerType": "TILE",

                "name": "ChinaDark",

                "url": "https://iserver.supermap.io/iserver/services/map-china/rest/maps/ChinaDark"

            },

            "layers": [

                {

                    "layerType": "VECTOR",

                    "visible": true,

                    "name": "Records of earthquakes of magnitude 6 or above in Chinese history",

                    "featureType": "POINT",

                    "xyField": {

                        "xField": "经度",

                        "yField": "纬度"

                    },

                    "style": {

                        "fillColor": "#EE4D5A",

                        "strokeWidth": 1,

                        "offsetX": 0,

                        "offsetY": 0,

                        "fillOpacity": 0.9,

                        "radius": 8,

                        "strokeColor": "#ffffff",

                        "type": "BASIC_POINT",

                        "strokeOpacity": 1

                    },

                    "projection": "EPSG:4326",

                    "enableFields": [

                        "Year",

                        "Month",

                        "Day",

                        "Time",

                        "Fen",

                        "Seconds",

                        "Longitude",

                        "Latitude",

                        "Depth",

                        "Magnitude",

                        "Magnitude Type",

                        "Reference place name"

                    ],

                    "dataSource": {

                        "name": "ChinaRecordOfOver6Earthquakes",

                        "type": "SAMPLE_DATA"

                    }

                }

            ],

            "description": "",

            "projection": "EPSG:3857",

            "minScale": "1:591658710.909",

            "title": "testdizhen",

            "version": "2.2.1",

            "rootUrl": "https://iptl.supermap.io/iportal/services/../"

        }

    }

}

Please note: When printing TianDiTu maps as WMTS service, server-side permission is required.

layoutOptions

The layoutOptions object is a required object that defines the layout information for the plot. Consists of the following parameters:

    Calculation parameters:

    Finishing parameters:

Example 1: Update the Layput Template, update the image of the North Arrow in the layout to the URL address, update the minimap to a WebMap layer, and update the legend to a JSON String

{

    "layoutOptions": {

        "templateName": "A4_landscape",

        "title": "title",

        "author": "authorName",

        "copyright": "copyright",

        "subTitle": "subTitle",

        "legendOptions": {

            "title": "legend",

            "customItems": [

                {

                    "name": "Railway",

                    "picAsUrl":

                        "http://192.168.120.40:8090/iserver/services/map-China100/rest/maps/China/layers/Main_Railway_L@China@@China/legend"

                },

                {

                    "name": "River",

                    "picAsUrl":

                        "http://192.168.120.40:8090/iserver/services/map-China100/rest/maps/China/layers/River@China@@China/legend"

                },

                {

                    "name": "Mainroad",

                    "picAsUrl":

                        "http://192.168.120.40:8090/iserver/services/map-China100/rest/maps/China/layers/Main_Road_L@China@@China/legend"

                },

                {

                    "name": "Airport",

                    "picAsUrl":

                        "http://192.168.120.40:8090/iserver/services/map-China100/rest/maps/China/layers/Airport_pt@China.1@@China/legend"

                }

            ]

        },

        "northArrowOptions": {

            "picAsUrl": "file://NorthArrow.svg"

        },

        "littleMapOptions": {

            "center": {

                "x": 12024583.8595938,

                "y": 4101942.08146721

            },

            "scale": 5.4085234291297E-08,

            "layers": [

                {

                    "layerType": "TILE",

                    "name": "China",

                    "url": "http://192.168.120.40:8090/iserver/services/map-China100/rest/maps/China"

                }

            ]

        }

    }

}

exportOptions

The exportOptions object is a required object that defines the Output Window for printing and consists of the following parameters:

Example: Update the printout format to PDF and print dpi to 300dpi

{

    "exportOptions": {

        "format": "PDF",

        "dpi": 300,

        "center": {

            "x": 100,

            "y": -10

        },

        "scale": 0.0001

    }

}

Automatic typesetting rules for legend element

The iServer Web Print Service provides users with automatic layout rules for legend elements. When the legend element in the Web print layout contains multiple legend subitems, the system can automatically typeset without manually adjusting the font size, margin and other parameters of the legend subitems.

The automatic typesetting function of legend elements is currently based on the rules of the legend item Show All. For specific parameters and setting methods, see layoutOptions . The specific rules are as follows:

Configure Web Printing Access Whitelist

Intranet penetration is a technology that enables intranet devices to break through LAN restrictions and achieve access from the extranet, and improper use may cause security problems such as data leakage and malicious attacks. When this configuration is enabled, only the addresses in the settings can be accessed through the request, effectively preventing the risk of other business systems being penetrated by the intranet through the Web Printing service.

The web printing access whitelist can be configured on the <externalUrlWhiteList> node in the [SuperMap iServer installation directory]\webapps\iserver\WEB-INF\iserver-system.xml file. The following is an example:

  <externalUrlWhiteList>
    <enabled>true</enabled> 
    <urlPatterns>
      <string>^https://maptiles\.supermapol\.com/iserver/services/.*?</string> 
      <string>^https://iserver\.supermap\.io/iserver/services/.*?</string>
    </urlPatterns>
  </externalUrlWhiteList>

Among them,

Please note:

1. If you need to enable the web printing access whitelist, you need to configure the service address of iPortal to enable WebApps to use the printing function, for example: ^http://localhost:8190/iportal/web/maps/.*?; If a third-party map is also referenced, you also need to configure the third-party service address here.

2. URLs that meet the following conditions do not need to be configured to print on-demand requests via the web

a)The host in the URL is the same as the host in the Web Printing service URL

b)The URL contains the local address (localhost/127.0.0.1/local IP) and the port is iServer port number/8190