Add Background Color to Label Fields Easily

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.

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": "[email protected]",
  "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' \

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: "[email protected]",
  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);
import boldsign

configuration = boldsign.Configuration(host = "https://api.boldsign.com", 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 = "[email protected]",
                signerOrder = 0,
                signerType = "Signer",
                formFields = [
                    boldsign.FormField(
                        id = "Signature",
                        fieldType = "Signature",
                        font = "Helvetica",
                        pageNumber = 1,
                        isRequired = False,
                        bounds = boldsign.Rectangle(x = 50, y = 50, width = 100, height = 150)
                    ),
                    boldsign.FormField(
                        id = "Label",
                        fieldType = "Label",
                        font = "Helvetica",
                        pageNumber = 1,
                        isRequired = False,
                        value = "Sample",
                        backgroundHexColor = "#FF00FF",
                        bounds = boldsign.Rectangle(x = 50, y = 50, width = 100, height = 150)
                    )
                ],
                privateMessage = "This is private message for signer"
            )
        ]
    )
    
    document_created = document_api.send_document(send_for_sign)
<?php require_once "vendor/autoload.php";

$config = new BoldSign\Configuration();
$config->setHost("https://api.boldsign.com");
$config->setApiKey('YOUR_API_KEY');

$documentApi = new BoldSign\Api\DocumentApi($config);

$signatureField = new BoldSign\Model\FormField();
$signatureField->setFieldType('Signature');
$signatureField->setPageNumber(1);
$signatureField->setBounds(new BoldSign\Model\Rectangle(['x' => 100, 'y' => 100, 'width' => 100, 'height' => 50]));

$labelField = new BoldSign\Model\FormField();
$labelField->setFieldType('Label');
$labelField->setPageNumber(1);
$labelField->setValue("Sample");
$labelField->setBackgroundHexColor("#FF00FF");
$labelField->setBounds(new BoldSign\Model\Rectangle(['x' => 200, 'y' => 400, 'width' => 100, 'height' => 50]));

$signer = new BoldSign\Model\DocumentSigner();
$signer->setName("Richard");
$signer->setEmailAddress("[email protected]");
$signer->setSignerType('Signer');
$signer->setFormFields([$signatureField, $labelField]);

$send_for_sign = new BoldSign\Model\SendForSign();
$send_for_sign->setTitle('Agreement');
$send_for_sign->setSigners([$signer]);
$send_for_sign->setFiles(['YOUR_FILE_PATH']);

$documentCreated = $documentApi->sendDocument($send_for_sign);
ApiClient client = Configuration.getDefaultApiClient();
client.setBasePath("https://api.boldsign.com");
client.setApiKey("YOUR_API_KEY");
DocumentApi documentApi = new DocumentApi(client);

FormField signatureField = new FormField();
signatureField.setFieldType(FormField.FieldTypeEnum.SIGNATURE);
signatureField.setPageNumber(1);
signatureField.setBounds(new Rectangle().x(100f).y(100f).width(100f).height(50f));

FormField labelField = new FormField();
labelField.setFieldType(FormField.FieldTypeEnum.LABEL);
labelField.setPageNumber(1);
labelField.setValue("Sample");
labelField.setBackgroundHexColor("#FF00FF");
labelField.setBounds(new Rectangle().x(200f).y(400f).width(100f).height(50f));

DocumentSigner signer = new DocumentSigner();
signer.setName("Richard");
signer.setEmailAddress("[email protected]");
signer.setSignerType(DocumentSigner.SignerTypeEnum.SIGNER);
signer.setFormFields(Arrays.asList(signatureField, labelField));

SendForSign sendForSign = new SendForSign();
sendForSign.setTitle("Agreement");
sendForSign.setSigners(Arrays.asList(signer));
sendForSign.setFiles(Arrays.asList(new File("YOUR_FILE_PATH"))); 

DocumentCreated document = documentApi.sendDocument(sendForSign);
import * as boldsign from "boldsign";
import * as fs from 'fs';

const documentApi = new boldsign.DocumentApi("https://api.boldsign.com");
documentApi.setApiKey('YOUR_API_KEY');

const signatureField = new boldsign.FormField();
signatureField.fieldType = boldsign.FormField.FieldTypeEnum.Signature;
signatureField.pageNumber = 1;
signatureField.bounds = new boldsign.Rectangle();
signatureField.bounds.x = 100;
signatureField.bounds.y = 200;
signatureField.bounds.width = 50;
signatureField.bounds.height = 60;

const labelField = new boldsign.FormField();
labelField.fieldType = boldsign.FormField.FieldTypeEnum.Label;
labelField.pageNumber = 1;
labelField.value = "Sample";
labelField.backgroundHexColor = "#FF00FF";
labelField.bounds = new boldsign.Rectangle();
labelField.bounds.x = 100;
labelField.bounds.y = 100;
labelField.bounds.width = 70;
labelField.bounds.height = 80;

const signer = new boldsign.DocumentSigner();
signer.name = "Richard";
signer.emailAddress = "[email protected]";
signer.signerType = boldsign.DocumentSigner.SignerTypeEnum.Signer;
signer.formFields = [signatureField, labelField];

const sendForSign = new boldsign.SendForSign();
sendForSign.title = "Agreement";
sendForSign.signers = [signer];
sendForSign.files = [fs.createReadStream("YOUR_FILE_PATH")];

documentApi.sendDocument(sendForSign);

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.