The SuperMap iServer Web printing service makes use of the layput template to output printable map documents. iServer supports loading layout templates made by SuperMap iDesktop/iDesktopX and Jaspersoft Studio. Where SuperMap layput templates generated by iDesktop/iDesktopX can be exported to ult files for distribution; templates generated by third-party software Jaspersoft Studio can be exported to distribute the jrxml file. The download address is https://community.jaspersoft.com/project/jaspersoft-studio .

Use Default Layput Template

Built into the iServer product package are layout templates made by SuperMap iDesktop/iDesktopX and Jaspersoft Studio, located in 【iServer root directory】/webapps/iserver/templates/web printing-layouts directory, each layput template is stored in a folder named Layout template.

SuperMap iDesktop/iDesktopX Default Layput Template

For the layput template made by SuperMap iDesktop/iDesktopX software, a template file named UGCLayoutTemplate is built into SuperMap iServer, and the folder of the same name contains the following contents:

Jaspersoft Studio Default layput template

For the layout template produced by Jaspersoft Studio, taking A4_landscape (A4 horizontal plate) as an example, the folder with the same name contains the following files:

In addition, several *.json request body examples are provided in the layput template folder, which can be referenced by the input request body when creating a print job.

You can also use the Get Request for Layout Templates Resource or direct access to iSrever layout list resource page (iserver/services/web printing/rest/v1/webprinting/layouts) looks at the information for all built-in layput templates. When creating a print job , the templateName parameter in the layoutOptions object in the request body specifies the name of the built-in layout template folder.

If the built-in layput template of iServer cannot meet your use requirements, you can change the layout element content by passing parameters, or customize the layout template according to your use requirements.

Change Layout Element Content by Passing Parameter

When creating a print task , you can update the layout element content in the request body by passing parameters, mainly in the request body modify the parameters in the layoutOptions object, as Described in Print Task List Resources POST Request . The following layout element contents can be modified:

Customize Layout Template

If changing the layout element content through the above method still cannot meet your requirements, you can also customize the layout template, such as adjusting the position of the layout element, deleting or adding the layout element, etc.

Via SuperMap iDesktop/iDesktopX customize layout template

You can directly modify the layput template generated by iServer's built-in SuperMap iDesktop/iDesktopX, or generate a new layput template, the print elements in the iServer's built-in template correspond to the map, map scale, north arrow, legend and text in the layout function of SuperMap iDesktop/iDesktopX software. Please refer to SuperMap iDesktop/iDesktopX Help for operational modifications.

If you choose to generate a new layput template, create a new folder under the iServer package Web print layout folder with the same name as the layput template file, and export the layput template (*.ult) to that folder. That is, 【iServer root directory】/webapps/iserver/templates/webprinting-layouts/【layput template filename】. After the above steps are completed, the iServer changes to the template are automatically detected and loaded for the new template to take effect.

Please note:

1. For map title, subtitle, author information, copyright information and other text content, in SuperMap iDesktop/iDesktopX is defined by text. When defining, text content needs to start with "$" and correspond to the parameters in the layout information (layoutOptions), such as "$title". If you need to specify a default value, it can be defined as "$title: World Map". When you need to input multiple lines of text, you can predefine the text box in the template and input the text content. When you input the text, you can type the new line as needed and set the alignment for the text. If you do not set it, the default is center alignment; You can also enter multiple lines of text in the request body by passing parameters, but you need to predefine a text box that can cover the range of text elements. See layoutOptions for details of parameter writing in the request body.

2. For the text scale defined in SuperMap iDesktop/iDesktopX, such as "1:1000000", you need to set the scaleBarVisible parameter settings in the layout information (layoutOptions) as False, and set the scaleText parameter settings to the corresponding string value, such as 1:1000000, to take effect during printing.

3. When you need to add an image to the map, such as the specified logo image, you need to use SuperMap iDesktop/iDesktopX add a rectangular face object to the template and imports the specified logo image into it.

4. When you create a layput template for Printing a National Standard Map Sheet Map , it is recommended that the template contain only the map element (the legend element is optional). Because there are related settings of map title, scale, compass and other elements in the standard marking options, and the map printing results can be generated more professionally according to the national standards in the standard marking mode. Therefore, if there are other layout elements in the layput template, it may cause problems such as duplicate printing elements and poor printing results.

Customize Layout templates with Jaspersoft Studio

You can directly modify the built-in Jaspersoft Studio layput template of iServer. After modification, the iServer changes to the template are automatically detected and loaded for the new template to take effect. Taking A4_landscape as an example, the following three files need to be modified:

  1. A4_landscape.jrxml file: Layput template file contains layout elements such as map title, north arrow, legend, scale, map author information, map copyright information and little map, which can be found in Make adjustments in Jaspersoft Studio software.
  2. legend.jrxml File: Template File of the legend, which can be found in Jaspersoft Adjust the legend in the Studio software. The legend includes two modes, one is the mode of directly transmitting the picture, in which the size of the legend picture should be _ landscape. Jrxml A4. The size of the legend in the file is kept consistent; the other is key-value form, that is, the element image and element name of the legend are passed in. The legend. Jrxml file defines the size of the legend element image, the width of the row where the legend element image + name is located, and the number of columns of the legend element.
  3. config.yaml File: Config file of the layput template. If a layout element is added or deleted, the corresponding part of the config fle needs to be modified synchronously.

The specific operation steps are as follows:

  1. Customize layout templates with Jaspersoft Studio.
  2. Modify the config.yaml file (If a layout element has been added or removed in Jaspersoft Studio software)

Jaspersoft studio software customize layout template

First, briefly introduce the main parts of Jaspersoft Studio software, as shown in the following figure:

  1. In the editing area of the layput template, the position and size of the added layout elements can be adjusted by dragging. Provided Design, Source, and Preview tabs. Preview tabs are not supported for map elements inserted by iServer.
  2. Elements in the layput template can be inserted. Elements used in the iServer built-in layput template include: Text Field (text), Image (picture), Subreport (for Add Map, little map, legend elements).
  3. Parameters, variables, etc. For each element in the layput template.
  4. The attribute window of the selected layout element. You can set the style of the layout element and the expression of the associated parameter.
  5. Shortcuts to preconfigured fields.
  6. Data connection (not available for iServer layput template).
  7. Information and error console.

As shown in form 2 above, the elements in the iServer built-in layput template correspond to the three elements in the Jaspersoft Studio software: Text Field (text), Image (picture), Subreport (subreport, used for Add Map, little map, legend elements), the following describes how to add or delete respectively.

Text Field (Text)

The map main title, subtitle, author information, and copyright information in the iServer built-in layput template all belong to the Text Field, and the adding method is the same. The specific steps are as follows:

  1. Add an element: Select Text Field in form 2 and draw a text element in area 1
  2. Create a new parameter: Right click parameters in area 3, select create parameter to create a new parameter, modify Name (Parameter Name) in area 4, and select Class java.lang.String。 You can also add parameters directly in the source view, using the following code:

<parameter name="title" class="java.lang.String"/>

  1. The added element is associated with the parameter by an expression: click the added layout element in area 1, and then select it in area 4. Text Field, click the button behind expression, in the pop-up dialog box, select parameters on the left, in the listed parameter list, double-click to select the newly added parameter, and click Finish。 You can also add the expression in the added element tag directly in the Source view, as shown in the following code:

<textField>

    ......

    <textFieldExpression><![CDATA[$P{subTitle}]]></textFieldExpression>

</textField>

Through the above three steps, a text element is added, you can also adjust the size of the text box, font, font size and so on.

Image

The compass and scale bar in the iServer built-in layput template belong to Image, and the adding method is the same. The specific steps are as follows:

  1. Add an element: Select Image in form 2 and draw an image element in area 1
  2. Create a new parameter: right click Parameters in area 3, select Create Parameter to create a new parameter, modify Name (Parameter Name) in area 4, and select Class java.lang.String。 You can also add parameters directly in the Source view, using the following code:

<parameter name="northArrowGraphic" class="java.lang.String"/>

  1. The added element is associated with the parameter through an expression: you can directly add an expression in the added element tag in the Source view. The code is as follows:

<image>

    ......

    <imageExpression><![CDATA[net.sf.jasperreports.renderers.BatikRenderer.getInstance(new java.io.File(new java.net.URI($P{northArrowGraphic})))]]></imageExpression>

</image>

Through the above three steps, a picture element is added, and you can also adjust the size, position and so on of the picture box.

Subreport

Maps, little maps, and legends in the iServer built-in layput template need to be added through Subreport in the same way. The specific steps are as follows:

  1. Add an element: Select Subreport in form 2 and draw a subreport element in area 1
  2. Create a new parameter: Right click Parameters in area 3, select Create Parameter to create a new parameter, modify Name (Parameter Name) in area 4, and select Class java.lang.String。 You can also add parameters directly in the Source view, using the following code:

<parameter name="mapSubReport1" class="java.lang.String"/>

  1. The added element is associated with the parameter through an expression: you can directly add an expression in the added element tag in the Source view. The code is as follows:

<subreport>

    ......

    <subreportExpression><![CDATA[$P{mapSubReport1}]]></subreportExpression>

</subreport>

Through the above three steps, a sub-report element is added. You can also adjust the size, position and so on of the sub-report.

If you want to delete the elements added above, you need to delete the elements in area 1, and delete the corresponding parameters in area 3.

Modify config.yaml films

For the layput template customized through Jaspersoft Studio software, if a certain layout element is added or deleted, you also need to add or delete relevant content in the config.yaml file. The following are the config. Yaml file contents and notes for the A4_land scape (A4 cross plate):

templates:

  #===========================================================================

  A4 landscape: !template

  #===========================================================================

    reportTemplate: A4_landscape.jrxml     //Layout template name

    attributes:                                            //Attribute information

      map: !map                                         //Map

        maxDpi: 400                                    //Maximum dpi of the map

        width: 800                                       //Width of map frame

        height: 410                                      //Height of map frame

      littleMap: !map                                  //Little map

        width: 150                                       //Width of little map frame

        height: 200                                      //Height of little map frame

        maxDpi: 400                                    //Maximum dpi of the little map

      title: !string {}                                     //The main title of the map

      subTitle: !string {}                               //The subtitle of the map

      copyright: !string {}                            //Copyright information for the map

      author: !string {}                                //Map author information

      legendOptions: !legend                                  //legend

        default:

          columnnumber: 3                          //The number of columns of the legend element. The default is 3 columns

      northArrowOptions: !northArrow             //The north arrow

        size: 40                                            //The frame of the north arrow

        createSubReport: false

        default:

          picAsUrl: "file://NorthArrow.svg"    //The picture of the north arrow

          backgroundColor: "rgba(214, 214, 214, 0)"        //The frame background color of the north arrow, default transparency

      scaleBarOptions: !scalebar                                                 //Scale bar

        width: 240                                                           //The width of the scale bar

        height: 50                                                           //The height of the scale bar

        createSubReport: false

        default:

          backgroundColor: "rgba(214, 214, 214, 0)"       //Background color of the scale bar, default transparency

          font: "boldface"                                                      //The font of the scale text

          fontSize: 12                                                     //Font size of scale bar text

          fontColor: "black"                                           //The font color of scale bar text

          scaleBarVisible: true                                        //Whether to display scale bar. Default value: true, displays scale bar

          align: "center"                                                 //The position of the scale

    processors:                                                            //Processors

    - !reportBuilder # compile all reports in current directory

      directory: '.'

    - !createMap                                                        //New map

      inputMapper:                                                     //Map input

        map: map                                                        //Types of maps

      outputMapper:                                                  //Map output

        mapSubReport: mapSubReport1                     //Map subreport name in Jaspersoft Studio software

        mapContext: mapContext1

    - !createMap                                                       //New little map

      inputMapper:                                                    //Little map input

        littleMap: map                                                 //Types of little maps

      outputMapper:                                                 //Little map output

        mapSubReport: mapSubReport2                     //Little map subreport name of Jaspersoft Studio software

        mapContext: mapContext2

    - !createScalebar                                                 //Create a new scale

        inputMapper:                                                  //Scale input

            mapContext1: mapContext                        //Scale specified map

    - !createNorthArrow                                          //New north arrow

        inputMapper:                                                 //North arrow input

            northArrowDef: northArrow                       //The type of the north arrow

            map: map                                                  //The map designated by the north arrow

    - !prepareLegend # create a datasource for the report with the 'legend' attribute

        template: legend.jrxml                                    //Associated legend template name

If you add or delete a layout element in the layput template customized by Jaspersoft Studio software, you need to add or delete the corresponding element contents in the attributes and processors of the config.yaml file.

Example 1: Remove the little map from the default layput template

  1. Download and install the Jaspersoft Studio software.
  2. Double-click the Open LayoutTe mplate File (located at 【root of iServer】/webapps/iserver/templates/web printing-layouts directory), take A3_landscape.jrxml as an example, open it in Jaspersoft Studio software, delete the two boxes of the little map shown in figure 1 below, and delete the parameters of the little map shown in figure 2.

  1. Delete the code of the little map part in the config.yaml, as shown in the following figure, and remove the content in the red box:

  1. When creating a print task, "littleMapOptions" does not need to be passed in the sent request body. As shown in the following figure, the contents in the red box are removed:

After completing the above modifications in steps 1, 2, and 3, restart the iServer, and then send the request body without the little map in step 4 to the iServer Web print service, and the output map document will have no little map.

Example 2: Add map's four corner

In view of some actual project requirements, By default, iServer provides an A3 horizontal layput template with four corner marks (located in 【iServer root directory】/webapps/iserver/templates/webprinting-layouts/A3_mapcornermarks folder). You can use this template directly when creating a print task. The effect is shown in the following figure.

Of course, you can also manually add the four corner tags in the existing default layput template in the following way. It should be noted that the function of adding four corner markers does not support the layput template with a little map. If there is a little map in the layput template you use, you need to refer to example 1 above to remove the little map.

  1. Download and install the Jaspersoft Studio software.
  2. Double-click the Open layoutTe mplate file (located at 【root of iServer】/webapps/iserver/templates/web printing-layouts in the directory, using the A4_landscape.jrxml as an example, open it in Jaspersoft Studio software
  3. It is recommended to add two StaticText as boxes for the four corner markers.
  4. Add a variable named mapCornerMarks of type java.lang.String.
  5. A total of 24 textFields need to be added for the four corner markers, and each textField Suggested size: 15 px in width, 12 px in height, and 6 in font Size. The Expression content of each textField corresponds to the actual meaning of the corner mark as shown in the following table:
textFieldExpression The actual meaning of corner mark
($P{mapCornerMarks}.split(","))[0] Degree of longitude on the upper left
($P{mapCornerMarks}.split(","))[1] Minutes of longitude on the upper left
($P{mapCornerMarks}.split(","))[2] Seconds of longitude on the upper left
($P{mapCornerMarks}.split(","))[3] Degree of longitude on the upper left
($P{mapCornerMarks}.split(","))[4] Minutes of longitude on the upper left
($P{mapCornerMarks}.split(","))[5] Seconds of longitude on the upper left
($P{mapCornerMarks}.split(","))[6] Degree of longitude on the upper left
($P{mapCornerMarks}.split(","))[7] Minutes of longitude on the upper left
($P{mapCornerMarks}.split(","))[8] Seconds of longitude on the upper left
($P{mapCornerMarks}.split(","))[9] Degree of longitude on the upper left
($P{mapCornerMarks}.split(","))[10] Minutes of longitude on the upper left
($P{mapCornerMarks}.split(","))[11] Seconds of longitude on the upper left
($P{mapCornerMarks}.split(","))[12] Degree of longitude on the upper left
($P{mapCornerMarks}.split(","))[13] Minutes of longitude on the upper left
($P{mapCornerMarks}.split(","))[14] Seconds of longitude on the upper left
($P{mapCornerMarks}.split(","))[15] Degree of longitude on the upper left
($P{mapCornerMarks}.split(","))[16] Minutes of longitude on the upper left
($P{mapCornerMarks}.split(","))[17] Seconds of longitude on the upper left
($P{mapCornerMarks}.split(","))[18] Degree of longitude on the upper left
($P{mapCornerMarks}.split(","))[19] Minutes of longitude on the upper left
($P{mapCornerMarks}.split(","))[20] Seconds of longitude on the upper left
($P{mapCornerMarks}.split(","))[21] Degree of longitude on the upper left
($P{mapCornerMarks}.split(","))[22] Minutes of longitude on the upper left
($P{mapCornerMarks}.split(","))[23] Seconds of longitude on the upper left
  1. Add the following to the config.yaml, as shown in bold:

      ......

      author: !string {}

      mapCornerMarks: !string

        default: ""

      legendOptions: !legend

      ......

  1. After completing the above steps, restart the iServer, and then send the request body of the layput template with four corner tags to After iServer's Web printing service, the output map document has four corner labels.