Skip to main content

Template format

Templates are defined as XML files, e.g.:

<?xml version="1.0" encoding="UTF-8"?>
<SignatureTemplateStyle>
<Description author="A-Trust GmBh" name="Sisi" description="A-Trust Standard Signatur Siegel" />
<Position type="relative" x="40.0" y="40.0" w="50.0" h="50.0" page="1" />
<B64bgImage>iVBORw0KGgoAAAANSUhEUgAAG[...]jhz/DwF8ylxAZ19</B64bgImage>
<Fields>
<Image x="150.0" y="0.0" w="800.0" h="200.0">/9j/4AAQSkZJRgAB[...]ABRRRQAUUUUAFFFFAH/9k=</Image>
</Fields>
</SignatureTemplateStyle>

The individual elements are described as follows:

Description

This is where meta-information, including author, name and description, is stored. The name is used by List templates

Position

This is where the position of the signature image in the PDF document is defined. The x and y coordinates define a corner of the signature image. It should be noted that the coordinate origin is the lower left corner of the PDF file. W and h define the image's second corner. These coordinates are expressed as percentages (page height / page width). The page onto which the signature image is to be placed has to be defined as well. Instead of 'relative', the position of the signature image may also be defined as 'absolute'.

B64bgImage

This is where the actual background image is saved as base64. Allowed file formats for background images are .png and .jpg.

Optional elements

Additional images

Further images may be added to the background image. These are defined in the <Fields> tags:

<Image x="0" y="0" w="150" h="150">Base64Content</Image>

The image itself is written into the XML document encoded in base64. All acceptable image formats only support JPEG and PNG. The x and y coordinates indicate the upper left point of the image in the background image. The w and h coordinates define the image extents. If they do not match the height or width of the image itself, the image is stretched or compressed. All coordinates (x, y, w, h) are expressed in pixels.

Examples

The following examples are based on a background image with a resolution of 800x300 and an additional image with a resolution of 100x100.

Original size image (X=0, Y=0, W=100, H=100)

Workflow

Stretched image (X=100, Y=100, W=300, H=200 ), as the original image measured 100x100 in size

Workflow

Compressed image (X=300, Y=200, W=50, H=50), as the original image measured 100x100 in size

Workflow

Image out of range (X=700, Y=200, W=200, H=200) Only the upper left part of the image is shown here; the remainder is outside the visible range.*

Workflow

Additional text

The text written on the signature image can also be defined. There are different text types: 'static' and 'dynamic'. The following attributes are needed:

  • type – static, dynamic (signer, location, reason, timestamp may also be used if no additional text is to be used with one of the dynamic elements)
  • x – The x position on the background image (coordinate origin is at the top left-hand corner)
  • y – The y position on the background image (coordinate origin is at the top left-hand corner)
  • w – width of the text field
  • h – obsolete
  • center – If the text is smaller than the text field, it can be centred using True.
  • wrap – obsolete
  • fgColor – as RGB values, e.g. (255, 255, 255)
  • bgColor – as RGB values, e.g. (255, 255, 255)
  • textSize - the size of the text (optional)

Type explained

  • static - static text
  • dynamic - Dynamic information can be written onto the signature image. For now, the following information is supported:
    • %timestamp – The time at which the signature is implemented (in the format DD.MM.YYYY HH:MM MET)
    • %signer – The signer implementing the signature (common name from the signature's certificate)
    • %location – The location where the signature is placed (from the method call)
    • %reason – The reason for the signature (from the method call)
  • signer - short form for signer
  • location - short form for location
  • reason - short form for reason
  • timestamp - short form for timestamp

Examples

A text field with text and the signer:

<Label type="dynamic" x="50.0" y="50.0" w="0.0" h="0.0" center="false" wrap="false" fgColor="(0,0,0)" bgColor="(255, 255, 255) textSize="26">Signiert von: %signer</Label>

A text field with only the signer:

<Label type="signer" x="50.0" y="50.0" w="0.0" h="0.0" center="false" wrap="false" fgColor="(0,0,0)" bgColor="(255, 255, 255) textSize="26"/>

Accessibility

It is possible to add an alt text for accessibility. The alt text must be defined in the XML of the Template, e.g.:

<Description author="Author Name" name="Test with alttext" description="This is a template with alttext" altText="This is the alt text" />

As templates can have dynamic information, the alt text can also use them. Just use the corresponding values, e.g.:\

<Description author="Author Name" name="Test with alttext" description="This is a template with alttext" altText="This document is signed from SIGNER=%signer at LOCATION=%location for REASON=%reason at TIMESTAMP=%timestamp." />