Use Scripts in Print Templates

In on-premises installations of VertiGIS Studio Printing, you can include C# scripts in your print templates.

Scripting allows print authors to write code that executes on your server. This can represent a security vulnerability if your print authors are not trusted.

Scripting is disabled by default. You can enable scripting if you want.

To use scripts in print templates, you must be familiar with C#.

Scripting is available in on-premises installations of VertiGIS Studio Printing only. Scripting is not available in cloud Printing.

In VertiGIS Studio Printing, scripts are custom event handlers. When you configure a script, you associate the script with a particular template element—a control, a band, or the print template itself—and a predefined event, such as Before Print or After Print. Each element in a print template has its own set of events. The event is fired relative to generation of the specified element. As the event handler, the script runs when the event is fired.

Example 1: If you associate the script with the Report Header band and After Print event, the script will run immediately after the Report Header is generated.

Example 2: If you associate the script with a particular control and the Before Print event, the script will run immediately before the control is generated.

The script runs as many times as the associated template element is generated.

Example 3: If you associate the script with the Page Footer band, the script will run once per page, because the Page Footer is generated once per page.

Example 4: If you associate the script with the Report Footer band, the script will run once, because the Report Footer is generated once.

Main Steps to Configure a Script

To add a script to a print template:

  1. Open the print template in Print Designer.

  2. Click Scripts to open the Script Editor.

  3. Specify when the script will run.

    To do this, you need to associate the script with a template element (a control, a band, or the print template itself) and an event. The event will be fired relative to generation of the specified element. The script is the event handler—it runs whenever the event is fired for the specified element.

    Configuring the template element and event is mandatory. If you skip this step, the script will not run.

    1. Select the element to associate the script with.

      Drop-down list in the Script Editor to associate the script with a template element

    2. Select the event.

      Drop-down list in the Script Editor to select the event

      The Script Editor creates a script stub. The script is named for the template element and event that you selected.

      Script stub created by the Script Editor

  4. Type or paste the remainder of the script into the stub.

    If you type the script, the Script Editor provides intelligent code completion as you type.

  5. Click Validate to validate the script.

  6. When the script is valid, click Designer to return to the design surface.

  7. To test your script, preview the print.