BoldSignDocumentation
BoldSign Mobile Icon

Send document for sign

Thu, 8 Apr, 2021

Upload documents

To send the document for signature the list of documents which needs to be signed should be added in IDocumentFile collection.

The below given table shows the different properties available in IDocumentFile and their description:

Property Description
ContentType Content mime type
FileData File data as bytes or stream
FileName File name
FilePath File path of the document to be uploaded

The document can be loaded as stream as shown in the code snippet below:

// Read document from local path as stream. 
using var fileStream = File.OpenRead("doc-2.docx"); 

var documentStream = new DocumentFileStream 
{ 
        ContentType = "application/docx", 
        FileData = fileStream, 
        FileName = "doc-2.docx", 
}; 

The document can be loaded as byte array as shown in the code snippet below:

// Read document from local path as byte array. 
var fileBytes = File.ReadAllBytes("doc-1.pdf"); 

var documentBytes = new DocumentFileBytes 
{ 
    ContentType = "application/pdf", 
    FileData = fileBytes, 
    FileName = "doc-1.pdf", 
}; 

The document can be loaded as stream or byte array or from a file path directly as shown in the code snippet below:

// Directly provide file path of the document. 
var documentFilePath = new DocumentFilePath 
{ 
    ContentType = "application/pdf", 
    FilePath = @"D:\doc-1.pdf", 
}; 

You can choose to upload multiple documents and add it in the filesToUpload collection mentioned in the below code:

// Creating collection with all loaded documents. 
var filesToUpload = new List<IDocumentFile> 
{ 
    documentBytes, 
    documentStream, 
    documentFilePath, 
};

The upload operation accepts file formats like .pdf, .png, .jpg, and .docx.

Total allowed page count per signature request in 1000 pages. Maximum file size allowed per document is 25 MB. The maximum number of allowed documents per signature request is 25.

Adding form fields

Now that the documents are loaded, you need to create the form fields to be signed by the signer.

The below given table shows the different properties available in form fields and their description:

Property Description
Name Name of the form field
Bounds Bounds of the field in the given page
PageNumber Page number in which the field needs to be placed
Type Field type of the form field
Font Font family of the content in the field
FontSize Font size of the content in the field
FontHexColor Hex color of the content in the field
IsBoldFont Boolean indicating whether the font style is bold
IsItalicFont Boolean indicating whether the font style is italic
IsUnderLineFont Boolean indicating whether the font style is underline
IsRequired Boolean indicating whether the field is required
LineHeight Height between each line
CharacterLimit Maximum number of characters allowed in the field.
GroupName Group name of a check box field.
Value Value of the form field

Below mentioned are the field types supported:

Field Type Description
Signature Signature field which can be filled by the signer
Initial Initial field which can be filled by the signer
CheckBox Check box field which can be filled by the signer
TextBox Text box field which can be filled by the signer
Label Label field that has default text set by the sender
RadioButton Radio button field which can be filled by signer.
Name Name filed which will contain the signer's name
Email Email field which will contain the signer's email

Below code demonstrates the creation of signature field and it is added to a form field collection.

// Creating signature field.
var signatureField = new FormField(
        name: "Sign",
        type: FieldType.Signature,
        pageNumber: 1,
        isRequired: true,
        bounds: new Rectangle(x: 50, y: 50, width: 200, height: 30));

// Adding the field to the collection.
List<FormField> formFeildsCollection = new List<FormField>();
formFeildsCollection.Add(signatureField);

You can choose to add multiple form field types to a particular signer.

The font can be specified to fields which contains text like text box, name, email, label, date signed field. The font can be chosen from 3 options which are given below:

  • Courier
  • Helvetica
  • Times new roman

The font style like Bold, Italic, Underline and font size can be specified along with line height as shown in the code below:

// Creating label  field.
var labelField = new FormField(
        name: "Label field",
        value: "Product price",
        type: FieldType.Label,
        pageNumber: 1,
        font: FontFamily.Courier,
        isBoldFont: true,
        isItalicFont: true,
        fontSize: 12,
        isRequired: true,
        bounds: new Rectangle(x: 150, y: 50, width: 200, height: 30));

List<FormField> formFeildsCollection = new List<FormField>();
formFeildsCollection.Add(labelField);

While adding text box field to document, you can specify the character limit for the field and line height that defines the space between the lines.

// Creating textbox field.
var textBoxField = new FormField(
        name: "Text box",
        type: FieldType.TextBox,
        isRequired: true,
        pageNumber: 1,
        font: FontFamily.Courier,
        fontSize: 12,
        characterLimit: 30,
        lineHeight: 14,
        bounds: new Rectangle(x: 120, y: 150, width: 200, height: 30));

// Adding the field to the collection.
List<FormField> formFeildsCollection = new List<FormField>();
formFeildsCollection.Add(textBoxField);

You can choose to add multiple form fields in the form fields collection and this collection can be assigned to a particular signer once the signer instance is created.

Adding textbox field

The textbox field is plain text input form field which will accepts any value provided by the signer.

Validation

Even though textbox field accepts any value, you can control and define what value are accepted by using validations. The textbox fields support number of built-in form validation as well as you own custom Regex validation to allow only certain characters or uppercase only etc. Validation can one of below types:

  1. Numbers only
  2. Email address
  3. Currency
  4. Custom Regex

var formFields = new List<FormField>()
{
    new TextBoxField(
        name: "Currency",
        pageNumber: 1,
        isRequired: true,
        validationType: ValidationType.Currency,
        bounds: new Rectangle(x: 50, y: 50, width: 200, height: 30)),

    new TextBoxField(
        name: "Numbers",
        pageNumber: 1,
        isRequired: true,
        validationType: ValidationType.NumbersOnly,
        bounds: new Rectangle(x: 50, y: 90, width: 200, height: 30)),

    new TextBoxField(
        name: "Email",
        pageNumber: 1,
        isRequired: true,
        validationType: ValidationType.EmailAddress,
        bounds: new Rectangle(x: 50, y: 120, width: 200, height: 30)),

    new TextBoxField(
        name: "Regex",
        pageNumber: 1,
        isRequired: true,
        validationType: ValidationType.CustomRegex,
        validationCustomRegex: new Regex(@"\b[S]\w+").ToString(),
        bounds: new Rectangle(x: 50, y: 160, width: 200, height: 30)),
};

Placeholder

The Textbox field also accepts placeholder value, which you can use to hint the signer to provide the appropriate value for a given textbox to complete the signing process.

var formFields = new List<FormField>()
{
    new TextBoxField(
        name: "Currency",
        pageNumber: 1,
        isRequired: true,
        placeholder: "Price in USD",
        validationType: ValidationType.Currency,
        bounds: new Rectangle(x: 50, y: 50, width: 200, height: 30)),

    new TextBoxField(
        name: "Numbers",
        pageNumber: 1,
        isRequired: true,
        placeholder: "Age",
        validationType: ValidationType.NumbersOnly,
        bounds: new Rectangle(x: 50, y: 90, width: 200, height: 30)),

    new TextBoxField(
        name: "Email",
        pageNumber: 1,
        isRequired: true,
        placeholder: "Email",
        validationType: ValidationType.EmailAddress,
        bounds: new Rectangle(x: 50, y: 120, width: 200, height: 30)),

    new TextBoxField(
        name: "Sign",
        pageNumber: 1,
        isRequired: true,
        placeholder: "Name in uppercase",
        validationType: ValidationType.CustomRegex,
        validationCustomRegex: new Regex(@"[A-Z]*").ToString(),
        bounds: new Rectangle(x: 50, y: 160, width: 200, height: 30)),
};

Adding date signed field

The date signed field is a date input form field which will contain the date on which the document is signed.

While sending document for signing the date signed field can be added along with other form field types.The Date field types supports different date formats which are given below:

  • MM/dd/yyyy
  • dd/MM/yyyy
  • dd-MMM-yyyy
  • MMM-dd-yyyy
  • MMM dd,yyyy
  • dd MMM,yyyy
  • yyyy,MMM dd
  • yyyy/MM/dd
  • dd-MM-yyyy
  • MM-dd-yyyy
  • yyyy-MM-dd

The default value for date format can be specified in the business profile setting present in your BoldSign application.

This date field can be added to send for sign request API using date signed field format dd/MM/yyyy with the help of below given code snippet:

C#

// Creating date signed field.
var dateField = new DateSignedField(name: "Sign",
            // Providing the date format type as string.
            dateFormat: "dd/MM/yyyy",
            pageNumber: 1,
            isRequired: true,
            bounds: new Rectangle(x: 50, y: 150, width: 200, height: 30));

// Creating signature field.
var signField = new FormField(
            name: "Sign",
            type: FieldType.Signature,
            pageNumber: 1,
            isRequired: true,
            bounds: new Rectangle(x: 50, y: 50, width: 200, height: 30));

// Adding the fields to the collection.
List<FormField> formFeildsCollection = new List<FormField>();
formFeildsCollection.Add(signField);
formFeildsCollection.Add(dateField);

Date signed field cannot be sent alone, it needs to be sent along with other required fields like signature, initial, textbox.

Adding Signer

Now, the documents are loaded, and the form fields are created. Next you need to add signers who need to sign the document and assign them with form fields.

The below given table shows the different properties available in DocumentSigner and their description:

Property Description
Name Name of the signer
EmailAddress Email address of the signer
PrivateMessage Private message to the signer
AuthenticationCode Authentication code for signing the document
SignerOrder Signing order of the signer
EnableEmailOTP Boolean to enable email OTP authentication for the signer
SignerType Signer type (Signer/ Reviewer)
FormFields Form field collection to be assigned to signer.

Create a new instance of DocumentSigner with all required signer information and assign the collection of form fields which is created in the last step.

// Creating signer field.
var signer = new DocumentSigner(
        name: "Signer Name 1",
        emailAddress: "signer1@email.com",
        signerOrder: 1,
        authenticationCode: "123",
        signerType: SignerType.Signer,
        privateMessage: "This is private message for signer",
        // Assign the created form fields to the signer.
        formFields: formFeildsCollection);

// Adding the signer to the collection.
var documentSigners = new List<DocumentSigner>
{
    signer
};

Adding CC

You can add the CC for the document sign request and set it while sending the document for sign request.

The added CC will be able to view, download, and send reminder for the document. Below mentioned code snippet creates a CC and adds it to a collection, which can be later added to the sign request.

// Creating a CC instance
var cc = new DocumentCC(emailAddress: "cc@mail.com");

// Adding the CC to the collection.
var documentCCs = new List<DocumentCC>
{
    cc
};

Adding labels

Labels are keywords or tag that you can add to the document and use them to categorize.

Labels can't contain spaces, are lower case, and can contain a maximum of 255 characters. You can add multiple labels to the document. If you want a label to include more than one word, use an underscore or hyphen.

// Adding the label to the collection.
var labels = new List<string>
{
    "labelname"
};

Setting reminder for the document

You can set the auto reminder to the document specifying the number of days and reminder count as shown below:

var reminderSetting = new ReminderSettings(reminderDays: 2, reminderCount: 2);

This reminder setting can be later added in the send for sign request.

Send document

The last step is to send the document for signing with the previously loaded document, form fields, and created signer.

The below given table shows the different properties available in SendForSign and their description:

Property Description
Files The files to be sent for signature
Title Title of the signature request
Message Message to be shown for the signers
Signers Signer collection containing information about all the signers
CC CC collection containing information about all the CC
EnableSigningOrder Boolean to enable signing order for the signers
ExpiryDays Integer representing the sign expiry in days.
ReminderSettings Reminder settings for the document sent
EnableEmbeddedSigning This property is deprecated and no longer works. Use DisableEmails property to stop sending emails for the document and status updates.
DisableEmails Boolean to stop sending emails for the document and status updates.
HideDocumentId Boolean to remove the document ID from all the pages of the document.

Create a new instance of SendForSign object with required parameters to send the sign request with the help of documentClient as shown below:

C#CURL

// Create send for sign request object.
var sendForign = new SendForSign
{
    Title = "Sent from API SDK",
    Message = "This is document message sent from API SDK",
    EnableSigningOrder = false,

    // Assign the loaded files collection.
    Files = filesToUpload,

    // Assign the signers collection.
    Signers = documentSigners,

    // Assign the signers collection.
    CC = documentCCs,

    // Assign the remonder setting for the document.
    ReminderSettings = reminderSetting,

    // Assign the labels for the document.
    Labels = labels,
};

// Send the document for signing.
var createdDocumentResult = this.DocumentClient.SendDocument(sendForign);
curl -X POST 'https://api.boldsign.com/v1/document/send' \
-H 'Authorization: Bearer <authtoken>' \
-F 'Title=Sent from API Curl' \
-F 'Message=This is document message sent from API Curl' \
-F 'EnableSigningOrder=false' \
-F 'Signers[0][Name]=Signer Name 1' \
-F 'Signers[0][EmailAddress]=signer1@email.com' \
-F 'Signers[0][SignerOrder]=1' \
-F 'Signers[0][authenticationCode]=1123' \
-F 'Signers[0][PrivateMessage]=This is private message for signer' \
-F 'Signers[0][FormFields][0][FieldType]=Signature' \
-F 'Signers[0][FormFields][0][Name]=Sign' \
-F 'Signers[0][FormFields][0][PageNumber]=1' \
-F 'Signers[0][FormFields][0][IsRequired]=True' \
-F 'Signers[0][FormFields][0][Bounds][X]=50' \
-F 'Signers[0][FormFields][0][Bounds][Y]=50' \
-F 'Signers[0][FormFields][0][Bounds][Width]=200' \
-F 'Signers[0][FormFields][0][Bounds][Height]=30' \
-F 'CC[0][emailAddress]=cc@mail.com' \
-F 'ReminderSettings.EnableAutoReminder=True' \
-F 'ReminderSettings.ReminderDays=2' \
-F 'ReminderSettings.ReminderCount=2' \
-F 'Labels[0]=labelname' \
-F 'Files=@NDA.pdf;type=application/pdf'

The return type createdDocumentResult will contain the document ID as shown below:

{
"documentId": "9c95ef588b109c988595018543aec8885390a5c8"
}

The document ID can be used in later stages to perform document specific operations.

Copied to clipboard