Skip to content

TMSFNCSignatureCapture

TTMSFNCUIPack123

The TMSFNCSignatureCapture is a component for capturing signatures that are made by the user. The signature can be cleared and saved in different file formats.

Clearing the signature

The signature is created by the user, similarly to when they are signing something on paper – but in this case by using their mouse. If the user clicks the clear icon it will clear the signature so they can recreate it to their liking. However, the signature can also be cleared programmatically by setting the TMSFNCSignatureCapture.Empty property to True.

Saving the signature

There are multiple ways to save the signature that has been created by the user. These methods include saving to a TMemoryStream, to a file or to an image.

To save the signature to a TMemoryStream, you can call the SaveToStream(AStream: TMemoryStream) method:

TForm1 = class(TForm)
 TMSFNCSignatureCapture1: TTMSFNCSignatureCapture;
 Button1: TButton;
 procedure FormCreate(Sender: TObject);
 procedure Button1Click(Sender: TObject);
private
 ms: TMemoryStream;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 ms := TMemoryStream.Create;
end;
procedure TForm1.Button1Click(Sender: TObject);

begin
 TMSFNCSignatureCapture1.SaveToStream(ms);
end;

To save the signature to a file, you can call the SaveToFile(FileName: string) method:

procedure TForm1.Button2Click(Sender: TObject);
begin
 TMSFNCSignatureCapture1.SaveToFile('signature.txt');
end;

And finally, to save a signature to an image, you can call the SaveToImageFile(FileName: string) method:

procedure TForm1.Button3Click(Sender: TObject);
begin
 TMSFNCSignatureCapture1.SaveToImageFile('signature.png');
end;

TTMSFNCUIPack124

Loading the signature

You can load a signature to the TMSFNCSignatureCapture component from a TMemoryStream if you have saved a signature to that stream. To do this, you can use the LoadFromStream(AStream: TMemoryStream) method:

procedure TForm1.Button4Click(Sender: TObject);
begin
 TMSFNCSignatureCapture1.LoadFromStream(ms);
end;
If you have saved a signature to a file, then you can load it from a file as well by calling the LoadFromFile(FileName: string) method:
procedure TForm1.Button5Click(Sender: TObject);
begin
 TMSFNCSignatureCapture1.LoadFromFile('signature.txt');
end;

Configuration

By default a ‘Sign here.’ text is displayed at the bottom of the TMSFNCSignatureCapture. To change this text, you can use the Text property. To change the position of this text, use the TextPosition property. To change the clear icon, use the ClearSig.Image property and to change its position, use the ClearSig.Position property.

The pen’s color, width and kind can also be changed via the Pen property.

TTMSFNCUIPack125

The text, the clear icon and the pen can be configured during design time or programmatically with the mentioned properties.

Properties

Property name Description
ClearSig The clear icon can be modified via the ClearSig property.
Empty Determines if the signature is empty. It can also clear the signature if it’s set to True programmatically.
Pen The pen that is used for signing can be modified via the Pen property.
Text The text that is being shown. The default value is ‘Sign here.’.
TextPosition The position of the text can be changed via the TextPosition property.

Methods

Method name Description
GetBase64Img Only accessible in the WEB. Returns the signature in Base64 format.
LoadFromFile(FileName: string) Not acccessible in the WEB. Loads a signature from a file that is given as a parameter.
LoadFromStream(AStream: TMemoryStream) Not acccessible in the WEB. Loads a signature
from a TMemoryStream that is given as a parameter.
SaveToFile(FileName: string) Not acccessible in the WEB. Saves the signature to the given file.
SaveToImageFile(FileName: string) Not acccessible in the WEB. Saves the signature to the given image file.
SaveToStream(AStream: TMemoryStream) Not acccessible in the WEB. Saves the signature to the given TMemoryStream.