Category / Section
How to allow signers to upload images before complete signing the electronic signature request via API?
Published:
8 mins read
This knowledge base article will guide you on setting Image form fields in BoldSign documents using the API. There are 2 ways to achieve this.
- Pre-define the Image field in the document before sending it.
- Allow signers to add them dynamically.
Send a document to the signer with Image fields:
You can set the Image
form field by providing imageInfo
object and you can add title
, description
and allowedFileExtensions
.
Supported Allowed File Extensions
- JPG or JPEG
- SVG
- PNG
- BMP
Code snippet
cURL
curl -X 'POST' \ 'https://api.boldsign.com/v1/document/send' \
-H 'accept: application/json' \
-H 'X-API-KEY: {your API key}' \
-H 'Content-Type: multipart/form-data' \
-F 'DisableExpiryAlert=false' \
-F 'ReminderSettings.ReminderDays=5' \
-F 'BrandId=' \
-F 'ReminderSettings.ReminderCount=3' \
-F 'EnableReassign=true' \
-F 'Message=' \
-F 'Signers={
"name": "hanky",
"emailAddress": "hankyWhites@gmail.com",
"signerType": "Signer",
"formFields": [
{
"id": "Image",
"name": "Image",
"fieldType": "Image",
"pageNumber": 1,
"isRequired": true,
"bounds": {
"x": 200,
"y": 200,
"width": 125,
"height": 25
},
"imageInfo": {
"title": "Add Image",
"description": "Image Description",
"allowedFileExtensions": ".jpg, .png"
}
}
],
"locale": "EN"
}' \
-F 'ExpiryDays=30' \
-F 'EnablePrintAndSign=false' \
-F 'AutoDetectFields=false' \
-F 'OnBehalfOf=' \
-F 'EnableSigningOrder=false' \
-F 'UseTextTags=false' \
-F 'SendLinkValidTill=' \
-F 'Files=@{your file}'
-F 'Title=Invitation form' \
-F 'HideDocumentId=false' \
-F 'EnableEmbeddedSigning=false' \
-F 'ExpiryDateType=Days' \
-F 'ReminderSettings.EnableAutoReminder=true' \
-F 'ExpiryValue=60' \
-F 'DisableEmails=false' \
-F 'DisableSMS=false'
C#
var apiClient = new ApiClient("https://api.boldsign.com", "{Your API key}");
var documentClient = new DocumentClient(apiClient);
var documentFilePath = new DocumentFilePath
{
ContentType = "application/pdf",
FilePath = "{Your File path}"
};
var filesToUpload = new List<IDocumentFile>
{
documentFilePath,
};
var imageField = new FormField(
id: "image",
isRequired: true,
type: FieldType.Image,
pageNumber: 1,
imageInfo: new ImageInfo(title: "Add Image", description: "Image Description", allowedFileExtensions: ".jpg, .png"),
bounds: new Rectangle(x: 100, y: 100, width: 125, height: 25));
var formFieldCollections = new List<FormField>()
{
imageField
};
var signer = new DocumentSigner(
signerName: "David",
signerType: SignerType.Signer,
signerEmail: "david@cubeflakes.com",
formFields: formFieldCollections,
locale: Locales.EN);
var documentSigners = new List<DocumentSigner>()
{
signer
};
var sendForSign = new SendForSign()
{
Message = "please sign this",
Title = "Agreement",
HideDocumentId = false,
Signers = documentSigners,
Files = filesToUpload
};
var documentCreated = documentClient.SendDocument(sendForSign);
Python
import boldsign
configuration = boldsign.Configuration(
api_key = "YOUR_API_KEY"
)
with boldsign.ApiClient(configuration) as api_client:
document_api = boldsign.DocumentApi(api_client)
send_for_sign = boldsign.SendForSign(
title="Document SDK API",
document_title = "SDK Document Test case",
description="Testing document from SDK integration test case",
files=["YOUR_FILE_PATH"],
signers=[
boldsign.DocumentSigner(
name="Hanky",
emailAddress="hankyWhites@cubeflakes.com",
signerOrder=1,
signerType="Signer",
formFields=[
boldsign.FormField(
name="Image",
fieldType="Image",
font="Helvetica",
pageNumber=1,
isRequired=True,
bounds=boldsign.Rectangle(x=50, y=50, width=100, height=150),
imageInfo=boldsign.ImageInfo(
title="Add Image",
description="Image Description",
allowedFileExtensions= ".jpg, .png"
)
)
],
privateMessage="This is private message for signer"
)
]
)
send_document_response = document_api.send_document(send_for_sign)
NodeJS
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
const form = new FormData();
form.append('DisableExpiryAlert', 'false');
form.append('ReminderSettings.ReminderDays', '3');
form.append('BrandId', '');
form.append('ReminderSettings.ReminderCount', '5');
form.append('EnableReassign', 'true');
form.append('Message', 'Please sign this.');
form.append('Signers', '{\n "name": "hanky",\n "emailAddress": "hankyWhites@gmail.com",\n "formFields": [\n {\n "fieldType": "Image",\n "pageNumber": 1,\n "bounds": {\n "x": 100,\n "y": 100,\n "width": 100,\n "height": 50\n },\n "isRequired": true,\n "imageInfo": {\n "title": "Add Image",\n "description": "Image Description",\n "allowedFileExtensions": ".jpg, .png"\n }\n }\n ]\n}');
form.append('ExpiryDays', '10');
form.append('EnablePrintAndSign', 'false');
form.append('AutoDetectFields', 'false');
form.append('OnBehalfOf', '');
form.append('EnableSigningOrder', 'false');
form.append('UseTextTags', 'false');
form.append('SendLinkValidTill', '');
form.append('Files', fs.readFileSync('agreement.pdf;type=application/pdf'), 'agreement.pdf;type=application/pdf');
form.append('Title', 'Agreement');
form.append('HideDocumentId', 'false');
form.append('EnableEmbeddedSigning', 'false');
form.append('ExpiryDateType', 'Days');
form.append('ReminderSettings.EnableAutoReminder', 'false');
form.append('ExpiryValue', '60');
form.append('DisableEmails', 'false');
form.append('DisableSMS', 'false');
const response = await axios.post(
'https://api.boldsign.com/v1/document/send',
form,
{
headers: {
...form.getHeaders(),
'accept': 'application/json',
'X-API-KEY': '{your API key}',
'Content-Type': 'multipart/form-data'
}
}
);
In the given example, replace the imageInfo
values with the desired values. Set the field type as Image
and give supported allowedFileExtensions
type. Upon executing the provided code, a document will be generated with the specified imageInfo
values for the Image
form fields.