.NET SDK Getting started

Uploading documents

Prepare to send a document for signing by creating a new instance of the DocumentClient, as shown in the following code example.

var documentClient = new DocumentClient(apiClient);

To send the document for signature, the list of documents that need to be signed should be added to the IDocumentFile collection.

Load the document as a stream and create an instance of DocumentFileStream with it, and add it to the IDocumentFile collection, as shown in the following code samples:

// 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>

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

File formats accepted by the upload operation include .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. The following code demonstrates the creation of a signature field and it is added to a form field collection.

// Creating signature field.
var signatureField = new FormField(
            id: "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> formFields = new List<FormField>();

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

Adding signers

The document and its form fields require signing. So, specify the signer to sign the form fields.

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

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

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

Send document to sign

Finally, send the document for signing with the specified document, form fields, and signer details.

// 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.