Articles in this section
Category / Section

How to provide background color for the label fields when sending document for signature?

Published:
6 mins read

BoldSign allows you to set a background color for label fields by using the BackgroundHexColor API when sending a document for signature. This article provides a guide on how to set a background color for label fields when sending a document for signature using the BoldSign API.

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 'Signers={
  "name": "Richard",
  "emailAddress": "richard@boldsign.dev",
  "formFields": [
    {
      "id": "sign",
      "fieldType": "Signature",
      "pageNumber": 1,
      "bounds": {
        "x": 100,
        "y": 100,
        "width": 200,
        "height": 20
      },
      "isRequired": true
    },
{
      "id": "label1",
      "fieldType": "Label",
      "pageNumber": 1,
      "bounds": {
        "x": 200,
        "y": 200,
        "width": 200,
        "height": 20
      },
      "isRequired": true,
       "value": "Sample",
      "backgroundHexColor": "#00FFFF"
    }
  ],
  "locale": "EN"
}' \
  -F 'Files=@{Your File Path}' \
  -F 'Title=Sample document' \

C#


using BoldSign.Api;
using BoldSign.Model;

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 signatureField = new FormField(
   id: "sign",
   isRequired: true,
   type:FieldType.Signature,
   pageNumber: 1,
   bounds: new Rectangle(x: 100, y: 100, width: 100, height: 50));

var labelField = new FormField(
   id: "label",
   isRequired: true,
   value:"Sample",
   type: FieldType.Label,
   pageNumber: 1,
   bounds: new Rectangle(x: 200, y: 400, width: 100, height: 50));   

labelField.BackgroundHexColor = "#FF00FF";  

var formFieldCollections = new List<FormField>()
{
    signatureField,
    labelField
};

var signer = new DocumentSigner(
  signerName: "Richard",
  signerType: SignerType.Signer,
  signerEmail: "richard@boldsign.dev",
  formFields: formFieldCollections,
  locale: Locales.EN);

var documentSigners = new List<DocumentSigner>()
{
    signer
};

var sendForSign = new SendForSign()
{
   Message = "please sign this",
   Title = "Agreement",
   Signers = documentSigners,
   Files = filesToUpload,

};
var documentCreated = documentClient.SendDocument(sendForSign);
Console.WriteLine(documentCreated.DocumentId);

Python


import boldsign

configuration = boldsign.Configuration(api_key="Your_API_Key")

with boldsign.ApiClient(configuration) as api_client:
    document_api = boldsign.DocumentApi(api_client)

    form_fields1 = [
        boldsign.FormField(
            fieldType="Signature",
            pageNumber=1,
            bounds=boldsign.Rectangle(x=50, y=50, width=200, height=25)
        ),
        boldsign.FormField(
            fieldType="Label",
            name="Label1",
            value="Sample",
            pageNumber=1,
            bounds=boldsign.Rectangle(x=150, y=250, width=200, height=25),
            backgroundHexColor="#00FFFF"
        ),
    ]

    document_signer1 = boldsign.DocumentSigner(
        name="Richard",
        emailAddress="richard@boldsign.dev",
        signerType="Signer",
        formFields=form_fields1,
    )

    send_for_sign = boldsign.SendForSign(
        title="Agreement",
        files=["Your_File_Path"], 
        signers=[document_signer1],
    )

    send_document_response = document_api.send_document(send_for_sign)

    print(send_document_response)

NodeJS

const axios = require('axios');
const fs = require('fs');
const FormData = require('form-data');

const url = "https://api.boldsign.com/v1/document/send";

const signerData = {
    name: "Richard",
    emailAddress: "richard@boldsign.dev",
    signerType: "Signer",
    formFields: [
        {
            id: "Sign1",
            name: "Sign1",
            fieldType: "Signature",
            pageNumber: 1,
            bounds: {
                x: 50,
                y: 50,
                width: 200,
                height: 25
            },
            isRequired: true
        },
        {
            id: "Label1",
            name: "Label1",
            fieldType: "Label",
            value:"Sample",
            pageNumber: 1,
            bounds: {
                x: 150,
                y: 250,
                width: 200,
                height: 25
            },
            isRequired: true,
            backgroundHexColor: "#00FFFF"
        }
    ],
    locale: "EN"
};

const formData = new FormData();
formData.append('Message', 'Please sign this.');
formData.append('Signers', JSON.stringify(signerData));
formData.append('Title', 'Agreement');
formData.append('Files', fs.createReadStream('{Your file path}'), 'application/pdf');

const headers = {
  'accept': 'application/json',
  'X-API-KEY': '{Your API Key}',
  ...formData.getHeaders()
};

axios.post(url, formData, { headers })
    .then(response => {
        console.log(response.data);
    })
    .catch(error => {
        console.error(error);
    });

In the provided code examples, make sure to update the SignerEmail and SignerName properties with the email and name of the signer you wish to send the document to, and replace the filepath with the actual path to your PDF file. Once the code is executed, the document will be sent for signature with label fields, including background color.

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
Access denied
Access denied