Skip to main content
Version: 10.0

Digital Signature

webPDF provides the Signature web service for the digital signing of PDF documents.

HTTP REST-APIOpenAPI
POST /signature/{documentId}🔗

A digital signature is used to define the current status of a document. This marks the authenticity of a document and any further changes to the document can be recognised. It is also possible to insert several signatures into the document or to certify a document conclusively. After that, no further changes can be made to the document.

Digital signatures (also known as electronic signatures) use a key pair consisting of a private (secret) signature key and a public key (verification key). The terms usually used here are ‘private key’ and ‘public key’.

webPDF requires an X.509 certificate with private keys to create an electronic signature. The certificate and the private key must be provided to webPDF via a configured keystore file or directly via the parameters of the /signature web service call.

The certificate and the private key must be passed to webPDF either
a) via the global keystore file or
b) directly as PEM data during the web service call

webPDF creates signatures for PDF documents based on an asymmetric encryption scheme also known as "public key cryptography."

caution

As of this writing, webPDF can generate qualified electronic signatures only if the required certificates can be provided on the server on an appropriate medium (e.g., file) and it is possible to configure access to them on the server.

Position and size of the visible appearance​

The position and size of a visible signature appearance are stated in the position element of the appearance parameter. Two properties of that parameter are worth knowing before you use it.

The unit is millimetres unless you say otherwise. The metrics attribute defaults to mm, so <position width="100"/> means 100 mm - not 100 points. Set metrics="pt" explicitly when you want to state PDF user space units.

webPDF applies no upper bound of its own to the requested size. A rectangle that is larger than the target page, or one positioned beyond its edge, is accepted and signed; a viewer simply clips whatever reaches past the page. The same holds for a signature field that a document already brings along - such a field is signed as the document states it, because refusing it would make a document unsignable that other producers accept.

A position or size that a PDF number cannot express is refused with the signature error code (-5012). This is a question of representability, not of size: it applies to a non-numeric value such as an infinite one, and to a finite value that only becomes infinite through the unit conversion - which is another reason to be aware of the millimetre default above.

Matching an existing signature field by name​

The fieldName parameter of the add operation is matched against existing form fields case-insensitively, and so is the check for a naming collision when a new field is created.

A field name that only differs in case still resolves to the existing field. Requesting fieldName: "signature2" for a document that already contains a field named Signature2 signs that field - no second field is created. PDF field names are case-sensitive per the PDF specification; webPDF relaxes that intentionally, so that a field a document already provides is not missed over a difference in spelling.

The same case-insensitive comparison applies when webPDF checks whether a new field name collides with an existing one. Requesting fieldName: "text1" next to an existing field named Text1 creates a field named text1_1, not a second field named text1.

Text and font of the visible appearance​

The text of a visible signature, for example the name of the signer, the reason, the location and the signing time, is drawn with a font that you can choose. The name attribute of the font element in the appearance parameter names it:

{
"signature": {
"add": {
"appearance": {
"font": {
"name": "Go Noto Current"
}
}
}
}
}

If name is empty or the element is missing, the default font of the Signature web service applies (see below). The value decides what happens, not whether the element is present. Blanks around the name are ignored, and a name of blanks only counts as no name.

ValueEffect
HelveticaThe PDF standard font Helvetica. The font is not embedded in the document, only the characters of the Windows Latin character set can be shown, and the text is laid out as in earlier versions of webPDF. The value always selects this standard font, also if a font family named Helvetica is installed.
A font named in the requestThe font is searched in the font directories of the Signature web service and embedded as a subset that holds only the characters drawn. The font is binding: a character that it cannot show ends the signature with the error SIGNATURE_APPEARANCE_CHARACTER_NOT_SUPPORTED (-337), and a font that is not found ends it with SIGNATURE_APPEARANCE_FONT_NOT_FOUND (-335).
No font in the request, a font named in defaultFontThe font is tried first. A character that it cannot show is drawn with the next of the fonts of the server that has it (see the next row), so the content of a certificate, which the caller does not control, does not prevent the signature. If the font is not found or cannot be used (it cannot be embedded or has no line metrics), a warning is written to the server log when the web service starts, and the other fonts of the server are used.
No font in the request and an empty defaultFontThe fonts of the server are tried in this order: "Go Noto Current", "Go Noto CJKCore", "Go Noto CJKExt", "Go Noto Emoji", "DejaVu Sans", "Arial Unicode MS" and, under Windows, "Arial" as a last resort. A character that the first of them cannot show is drawn with the next font that has it, so that a name or a label in another script does not prevent the signature. A character that none of them can show ends the signature with SIGNATURE_APPEARANCE_CHARACTER_NOT_SUPPORTED (-337).

With an embedded font, webPDF fits the text into the signature field: it chooses the largest font size at which the text fits and breaks the text into lines at the line breaks of the text and between words (and between Chinese or Japanese characters). A word is split only if it does not fit into a line even at the smallest font size, so parts such as a time 14:30:00 or an offset +02:00 are never broken. The text is drawn in black in an ICC based color space (sRGB), which needs no output intent in a PDF/A document, and no placeholder image is drawn if the request names no image. If the text does not fit even at the smallest font size, the signature ends with the error SIGNATURE_APPEARANCE_TEXT_TOO_LARGE (-338) - unless the request asked for no appearance (see prepared signature fields).

A font that is not found ends the signature with SIGNATURE_APPEARANCE_FONT_NOT_FOUND (-335), and a font that cannot be embedded, for example because the font file cannot be used for embedding, with SIGNATURE_APPEARANCE_FONT_NOT_USABLE (-336). See the error codes.

caution

webPDF does not shape or reorder text. Characters of scripts that are written right to left or that need contextual shaping, for example Arabic, Hebrew, Hindi and Thai, are drawn one by one, without shaping and in the order in which they are given, so the result is not correct for such text even if the font contains the characters. This applies to text that you pass as well as to the values of the certificate.

Prepared signature fields​

A signature without an appearance element is invisible - unless the document prepares the signature field it is written into (fieldName) with a widget whose rectangle can carry an appearance. Since 10.0.8, webPDF then gives that field a visible appearance itself, drawn like one without further settings: with the fonts of the Signature web service, embedded in the document, and in the time zone of the operation - the one of the Signature web service, or, for the signature of a conversion, the one of the conversion. Without a configured time zone, the time zone of the Java runtime applies. The date is written in the iso form, so the locale has no visible effect (see date and time zone).

If defaultFont of the Signature web service is Helvetica, the text is drawn with the PDF standard font as described for font above; the date still follows a configured time zone. Otherwise, if the text does not fit into the field even at the smallest font size, the field gets an appearance without text, and the signature is created all the same; the field shows both texts or none. A character that no font of the server can show ends the signature with SIGNATURE_APPEARANCE_CHARACTER_NOT_SUPPORTED (-337), as for a requested appearance. On a server without fonts, the text is drawn with the standard font Helvetica as described under configuration of the Signature web service.

PDF/A documents​

A signature normally removes the PDF/A marking of a document: the default of pdfaEditProfile is removePdfaMetadata (see PDF/A settings). With pdfaEditProfile set to noEditRestrictions, the marking is kept. In that case the font decides whether the visible appearance conforms to PDF/A:

  • With Helvetica, the appearance violates PDF/A because the font is not embedded.
  • With an embedded font, the appearance does not violate PDF/A.

Date and time zone of the visible appearance​

If showDate of the identifierElements element is enabled, the appearance shows the signing time. These attributes of identifierElements control how:

AttributeEffect
textDateThe label in front of the date. A label that you set is used as given, independently of locale; if it is empty, Date: is used. webPDF does not translate labels, so set textSignedBy and textDate in the language you need.
dateFormatiso (default): date and time as 2026-10-06 14:30:00 +02:00 (Z for UTC). localized: date and time in the medium format of the locale, followed by the offset from UTC, for example 06.10.2026, 14:30:00 +02:00 for de-DE.
timeZoneThe time zone in which the date is shown: an identifier known to the Java runtime of the server, such as Europe/Berlin, or an offset such as +01:00.
localeThe locale of the date as a language tag such as de-DE or en-US. It takes effect only with dateFormat set to localized.
{
"signature": {
"add": {
"appearance": {
"identifierElements": {
"showDate": true,
"textDate": "Datum:",
"dateFormat": "localized",
"locale": "de-DE",
"timeZone": "Europe/Berlin"
}
}
}
}
}

For timeZone and locale separately, webPDF uses the first value that is set:

  1. The attribute of identifierElements.
  2. For a signature that is part of a conversion: the attribute of the converter parameter node, then the default of the Converter web service. For a call of the Signature web service: the default of the Signature web service.
  3. The default of the server (locale and timeZone of webservices).
  4. The Java runtime of the server.

An empty value counts as not set. Without any of these values, the date is written in the iso form in the time zone of the Java runtime, as in earlier versions. The effect per conversion path lists where the same values apply elsewhere.

note
  • The localized form is used only with an embedded font. With Helvetica, and for locales whose date format needs a script that is written right to left or needs contextual shaping (for example Arabic, Hebrew, Hindi and Thai), the date is written in the iso form. It is also written in the iso form if the fonts of the signature cannot show a character of the localized date, for example the date of zh-CN with a font that has only Latin characters.
  • The medium date format of a locale comes from the Java runtime of the server and can differ slightly between Java versions, for example in a separator or a space.
  • The signing time that is stored in the signature does not change, and PDF viewers show it in their own local time. Only the text in the appearance follows the time zone.

Configuration of the Signature web service​

The signature element in the webservices section of application.xml has these attributes, in addition to the common settings of a web service:

AttributeDefaultDescription
fontPathemptyThe base path, including subfolders, from which the fonts for the text of visible signatures are read. Empty means the font directories of the operating system. The font folder of the user account that runs the server is read in addition, with its subfolders; with a configured fontPath only as long as useUserFonts is not false. A configured directory that cannot be used keeps the web service from starting (see below).
useUserFontstrueSince 10.0.8. Applies only when fontPath is set: true also reads the font folder of the user account that runs the server, false reads only fontPath and its subfolders (see custom font directory).
defaultFontemptyThe first font for requests that name none. Empty means the fonts of the server in the order given above; Helvetica selects the standard font. A font that you name here is preferred, not binding: characters it cannot show are drawn with the other fonts of the server. If it is not found or cannot be used, the server log reports it when the web service starts.
localeemptyThe default locale of the date of visible signatures. Empty means the default of the server.
timeZoneemptyThe default time zone of the date of visible signatures. Empty means the default of the server.

To take a value from the environment of the server, use a placeholder ${VARIABLE:-default} in the attribute. When the file is loaded, webPDF replaces it with the value of the environment variable VARIABLE, or with default if the variable is not set; with an empty default, the attribute stays empty. The defaults of the server are described under defaults of the server and of the web services.

The settings are read when the server starts; a change takes effect after a restart. Invalid values are handled in two steps:

  • Wrong form of locale or timeZone: the configuration cannot be loaded and the server does not start.
  • Correct form, but unknown to the Java runtime: the Signature web service does not start, the other web services run. The server log names the setting and the value.

If fontPath is set and the directory cannot be used - it does not exist or cannot be read, or no font is found in it, in its subfolders and, as long as useUserFonts is not false, in the font folder of the user account - the Signature web service does not start, and the server log names the directory and the attribute.

Without fontPath, the Signature web service also starts if no font can be read from the font directories of the operating system. It then writes a warning to the server log and draws the text of visible signatures with the standard font Helvetica, which is not embedded: the text is still fitted into the signature field, characters outside the Windows Latin character set end the signature with SIGNATURE_APPEARANCE_CHARACTER_NOT_SUPPORTED (-337), and a font that is named in the request is not found (SIGNATURE_APPEARANCE_FONT_NOT_FOUND, -335). A signature field that the document prepares and that is signed without an appearance element is drawn the same way (see prepared signature fields). A signature without a visible appearance needs no font. The font directories apply to the Signature web service only, also when a conversion signs its result, and do not change the fonts of the other web services. For the directories that are scanned by default and for what else applies to fonts, see fonts. The configuration check locale of the administration API also validates locale and timeZone of the Signature web service.

caution

Behavior change in webPDF 10.0.7: the default of defaultFont is empty. A visible signature is now drawn with an embedded font from the fonts of the server, and the text is fitted into the signature field and broken into lines; names in scripts beyond the Windows Latin character set are shown correctly. Earlier versions drew the text with the font Helvetica, which is not embedded, and could not show such names. A signature can now also end with an error where it previously succeeded: a character that none of the fonts of the server can show ends it with SIGNATURE_APPEARANCE_CHARACTER_NOT_SUPPORTED (-337), and a text that does not fit into the signature field even at the smallest font size with SIGNATURE_APPEARANCE_TEXT_TOO_LARGE (-338). The signed document grows by the embedded font subset (about 10 to 20 KB, depending on the font), and creating a signature takes somewhat longer. If you want the earlier appearance, set defaultFont to Helvetica in application.xml.

caution

Behavior change in webPDF 10.0.8: a signature without an appearance element that is written into a signature field prepared by the document (see prepared signature fields) is now drawn like a requested appearance without further settings: with an embedded font from the fonts of the server instead of the font Helvetica, with the text fitted into the field and without a placeholder image, and with the date in the configured time zone instead of the time zone of the Java runtime. The field shows both texts or none; before, one of them could be missing. A character that none of the fonts of the server can show now ends the signature with SIGNATURE_APPEARANCE_CHARACTER_NOT_SUPPORTED (-337) where it previously succeeded with wrong characters in the appearance. The signed document grows by the embedded font subset. To get the former appearance back, set defaultFont of the Signature web service to Helvetica: font and layout are then as before, and only the date follows a configured time zone. A request with an appearance element and a signature without a prepared field are not affected.

Remove signatures while preserving the visual appearance​

The Signature web service can also be used to remove existing digital signatures from a PDF document. If the visible signature appearance should remain visible in the document, use the clear operation with flatten=true.

This is useful when a signed PDF document must still be processed further, for example before a toolbox.merge call. In that case, the visible signature appearance is rendered into the normal page content, while the actual digital signature is removed.

{
"signature": {
"clear": {
"flatten": true
}
}
}
info

When flatten is set to true, the visible appearance of the signature remains visible in the resulting PDF document, but the actual digital signature is still removed.

caution

The remaining visual representation is not verifiable and does not count as a valid digital signature.

If the signed input document is still protected against modifications, also set settings.signature.signatureEditProfile to noEditRestrictions for that call.

{
"signature": {
"clear": {
"flatten": true
}
},
"settings": {
"signature": {
"signatureEditProfile": "noEditRestrictions"
}
}
}

For merge scenarios with signed input documents, the recommended processing sequence is:

  1. Prepare each signed input document with signature.clear and flatten=true
  2. Merge the prepared PDF documents with toolbox.merge

See also:

Use of the global keystore​

webPDF uses a global keystore on the server to provide certificates (“public key” and “private” key) for the web service calls.

API {REST}: /signature

can be used to use this global keystore.

info

The global certificate store applies to all web service calls to the server.

In the parameters of the web service call, the corresponding certificate is then selected from the global keystore using the add operation with the keyName and keyPassword parameters.

{
"signature": {
"add": {
"appendSignature": false,
"certificationLevel": "none",
"contact": "",
"fieldName": "Signature1",
"keyName": "name",
"keyPassword": "password",
"location": "",
"reason": ""
}
}
}

The (alias) name of the certificate under which it is stored in the global keystore is specified by keyName. If the private key for the certificate is protected in the global keystore, a password can (optionally) be specified with keyPassword.

tip

If you want to use a different certificate for each web service call, you can use the PEM format and the keyPair parameter.

Use of individual certificates​

webPDF uses a global keystore to provide certificates for all web service calls. However, if an individual certificate is to be used for a single web service call with

API {REST}: /signature

this is possible via the parameters of the web service call as a PEM format. In this case, the certificate, consisting of a public key and a private key, is transferred directly to the parameter under signer.

{
"signature": {
"add": {
"appendSignature": true,
"certificationLevel": "none",
"contact": "",
"fieldName": "Signature1",
"location": "",
"reason": "",
"signer": {
"keyPair": {
"certificate": {
"source": "value",
"uri": "",
"value": "-----BEGIN CERTIFICATE-----\r\nMIIF+TCCBOGgAwIBA ... idstK36dRILKz7OA54=\r\n-----END CERTIFICATE-----\r\n"
},
"privateKey": {
"password": "password",
"source": "value",
"uri": "",
"value": "-----BEGIN RSA PRIVATE KEY-----\r\nMIIJKgIBAAKCA ... gDxWRoBg==\r\n-----END RSA PRIVATE KEY-----"
}
}
}
}
}
}
note

If the private key is encrypted, then you must provide the corresponding password under password.