DynaPDF.CreateSigField
----------------------

Creates an empty signature field which can be used to digitally sign the PDF file.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [DynaPDF](component_DynaPDF.md) | [4.2](newinversion42.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "DynaPDF.CreateSigField"; PDF; Name; Parent; PosX; PosY; Width; Height ) 

**MBS**( **"DynaPDF.CreateSigField";** /\* Creates an empty signature field which can be used to digitally sign the PDF file. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$Name**; /\* Name of the fielde.g. "MySignature" \*/   
**$Parent**; /\* Parent group field if any or -1.e.g. -1 \*/   
**$PosX**; /\* X-Coordinate of the text field.e.g. 100 \*/   
**$PosY**; /\* Y-Coordinate of the text field.e.g. 100 \*/   
**$Width**; /\* Width of the text field.e.g. 100 \*/   
**$Height**) /\* Height of the text field.e.g. 20 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |
| Name | Name of the field | "MySignature" |
| Parent | Parent group field if any or -1. | -1 |
| PosX | X-Coordinate of the text field. | 100 |
| PosY | Y-Coordinate of the text field. | 100 |
| Width | Width of the text field. | 100 |
| Height | Height of the text field. | 20 |

### Result

Returns handle or error message.

### Description

Creates an empty signature field which can be used to digitally sign the PDF file.   
If the coordinate system is bottom-up the point PosX, PosY defines the lower left corner of the signature field. If the coordinate system is top-down it defines the upper left corner.  
  
Like all form fields, the width and height is measured incl. the line width of the border. The size of normal vector graphics is measured without the line width; this must be taken into account when calculating the width or height of a form field. The line width of the border is derived from the current graphics state (see [DynaPDF.SetLineWidth](DynaPDFSetLineWidth.md)), it should be either 0, 1, 2, or 3 units (no border, thin, medium, or thick). The border style can be changed with the functions [DynaPDF.SetBorderStyle](DynaPDFSetBorderStyle.md) or [DynaPDF.SetFieldBorderStyle](DynaPDFSetFieldBorderStyle.md).  
If the PDF file should be digitally signed by DynaPDF call the function DynaPDF.CloseAndSignFile or DynaPDF.CloseAndSignFileEx after all pages has been created. The first signature field is used for signing if multiple signature fields exist. In this case it is also possible to create a user defined appearance for the signature field. See CreateSigFieldAP() for further information.  
  
A signature field can be visible or invisible depending on your requirements. To create a hidden signature field set the flag ffHidden to the field (see also [DynaPDF.SetFieldFlags](DynaPDFSetFieldFlags.md)).  
  
How to lock an Interactive Form after signing?  
  
If an Interactive Form should be filled in and signed within the full version of Adobe's Acrobat 4 or higher then it is possible to create an empty signature field which executes a special JavaScript Action to lock the form after it has been signed. This can be done with a JavaScript Action which contains the JavaScript function AFSignature\_Format(). This function can be called within the OnFormat event of the signature field. Note that this is the one and only event that signature fields support.  
  
The function supports two parameters, the first parameter defines whether all or only specific fields should be locked, the second parameter contains either an empty array or an array of full qualified field names delimited by a comma:  
  
- AFSignature\_Format("ALL", new Array ("")");
- AFSignature\_Format("THESE", new Array ("Field1, Field2")");
- AFSignature\_Format("EXCEPT", new Array ("Field1, Field2")");

  
If a form contains a button with a Submit Form Action then it is recommended to exclude the button field from locking so that it is still possible to submit the form data. Otherwise, the entire form is locked, incl. the submit button, and it is impossible to submit the form data to a web server.  
  
If you see errors in Acrobat Reader with signing multiple fields, please try [DynaPDF.CreateStructureTree](DynaPDFCreateStructureTree.md) function and test whether it works then.  
See also [CreateSigField](https://www.monkeybreadsoftware.com/DynaPDF-Manual/CreateSigField.shtml) function in DynaPDF manual.

### Examples

Creates signature field:

 MBS ("DynaPDF.CreateSigField"; $pdf ; Create Form::Name ; -1; Create Form::PosX ; Create Form::PosY ; Create Form::Width ; Create Form::Height )  
Add a signature field:

 # get a page imported before, so we can now edit the page   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.EditPage](DynaPDFEditPage.md)"; $pdf ; 1) \]   
\#   
\# create a signature field on the page   
Set Variable \[ $r ; Value: MBS ("DynaPDF.CreateSigField"; $pdf ; "Signature1"; -1; 356; 650; 184; 12) \]   
\#   
\# now you can close page and later save   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.EndPage](DynaPDFEndPage.md)"; $pdf ) \]  
### See also

- [DynaPDF.CreateGroupField](DynaPDFCreateGroupField.md)
- [DynaPDF.CreateSigFieldAP](DynaPDFCreateSigFieldAP.md)
- [DynaPDF.CreateStructureTree](DynaPDFCreateStructureTree.md)
- [DynaPDF.CreateTextField](DynaPDFCreateTextField.md)
- [DynaPDF.EditPage](DynaPDFEditPage.md)
- [DynaPDF.EndPage](DynaPDFEndPage.md)
- [DynaPDF.New](DynaPDFNew.md)
- [DynaPDF.PlaceSigFieldValidateIcon](DynaPDFPlaceSigFieldValidateIcon.md)
- [DynaPDF.SetBorderStyle](DynaPDFSetBorderStyle.md)
- [DynaPDF.SetLineWidth](DynaPDFSetLineWidth.md)

### Example Databases

- [DynaPDF/Create Form](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Create%20Form.shtml#2ScriptAnchor_)
- [DynaPDF/Signature Appearance](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Signature%20Appearance.shtml#1ScriptAnchor_)

### Blog Entries

- [Things you can do with DynaPDF](https://www.mbsplugins.de/archive/2021-07-02/Things_you_can_do_with_DynaPDF/monkeybreadsoftware_blog_filemaker)
- [Digitally signing PDF with DynaPDF and custom signature appearance](https://www.mbsplugins.de/archive/2020-04-22/Digitally_signing_PDF_with_Dyn/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 4.2pr5](https://www.mbsplugins.de/archive/2014-05-10/MBS_Filemaker_Plugin_version_4/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 21st July 2023

  
[DynaPDF.CreateSeparationCS](DynaPDFCreateSeparationCS.md) - [DynaPDF.CreateSigFieldAP](DynaPDFCreateSigFieldAP.md)

[HTML Version](DynaPDFCreateSigField.shtml)