Preprocessing the PDF

Prerequisites

It may be the case that you don’t have a license of Adobe Acrobat or something similar to create a PDF with signatures and/or fillable fields. For instance, you generate your PDF using Microsoft Word.

For these cases, Web Trust allows you to specify special placeholders that will be preprocessed and replaced in the PDF using the appropriate fields.

To use the functionality, it is enough to set the property preprocess to an array that can contain SIGNATURE_PLACEHOLDERS and/or TEXTFIELD_PLACEHOLDERS while creating the signature.

Signature placeholders

SIGNATURE_PLACEHOLDERS will replace with signature fields all matches of the following regular expression sigs_[a-zA-Z0-9]+(_([0-9]+x[0-9]+|-+))?_sige inside the PDF.

The middle part of the regular expression should be a string indicating the name of the signature field (that should be unique inside the PDF), and optionally it could be appended the following: _-+ or _[0-9]+x[0-9]+.

  • _-+ is a sequence of one or more - and

  • _[0-9]+x[0-9]+ represents WIDTHxHEIGHT of the signature field that will be created.

Note that you can use a WYSIWYG method to create the placeholder, changing font size to adjust height and using the -s to finally adjust width.

Here are some examples:

  • sigs_name1_sige: Is a signature with name name1, and using the font specified, to compute width and height.

  • sigs_name2_---------_sige: (Assuming it has a bigger font) Is a signature with name name2, with the specified font and the width adjusted using the -s.

  • sigs_name3_300x100_sige: Is a signature with name name3, with width = 300 and height = 100.

The signatures will be placed using the coordinates X,Y of the placeholder inside the PDF.

The coordinate system of a PDF has its 0x0 in the lower left corner, so the width grows to the right and the height upwards.

Textfield placeholders

TEXTFIELD_PLACEHOLDERSwill replace with text fields all matches of the following regular expression: txs_[a-zA-Z0-9]+_ro?_txe inside the PDF.

The middle part of the regular expression should be a string indicating the name of the text field (that should be unique inside the PDF), the fact that it is required or optional, and optionally it could be appended the following: _-+ or _[0-9]+x[0-9]+, like for the signature placeholders.

Here are some examples:

  • txs_name1_r_txe: Is a required text field with name name1, and using the font specified.

  • txs_name2_o_---------_txe: (Assuming it has a bigger font) is an optional text field with name name2, with the specified font and the width adjusted using the -s.

  • txs_name3_r_300x100_txe: Is a required text field with name name3, with width = 300 and height = 100.

An example PDF

As you can see here, in this PDF we created two text fields, one required and one optional, using two different sizing techniques. Moreover, there are two signature fields.