BoldSignDocumentation
BoldSign Mobile Icon

Getting started

Thu, 31 Mar, 2021

The best way to get started would be to read the "Preparing your application" section of the documentation for the application that you would like to start using first.

Prepare to send document for signing by creating new instance of the DocumentClient as shown below.

var documentClient = new DocumentClient(apiClient);

Uploading documents

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

Load the document as stream and create an instance of DocumentFileStream with it and add it to the IDocumentFile collection as shown below:

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

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


// Creating collection with loaded document.
var filesToUpload = new List<IDocumentFile>
{
documentStream,
};

You can also upload multiple documents and add it in the filesToUpload collection mentioned in the above code. The document can also be loaded as byte array or directly from a file path.

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

Adding form fields

Now that the documents are loaded, we need to create the form fields to be signed or filled by the signer. 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> formFeilds = new List<FormField>();
formFeilds.Add(signatureField);

You can also add multiple form fields in the form fields collection and this collection can be assigned to a particular signer.

Adding Signer

Now, the document and the form fields that requires signing, and specify the signer to be signed the form fields.

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: formFeilds);

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

Send document to sign

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

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

// Assign the signers collection.
Signers = documentSigners,

// Assign the loaded files collection.
Files = filesToUpload
};

// Send the document for signing.
var createdDocumentResult = documentClient.SendDocument(sendForSign);

The return type createdDocumentResult will contain the document id of the document created which can be used in later stages to get the particular document related operations.