Signature Appliance Local API C#: Signing Word .docx documents

This recipe demonstrates how to use the Local API to digitally sign a MS Office .docx document.

API Recipe source files are available on GitHub.

When signing MS Word and Excel files (.docx and .xlsx), signature fields must be created in the documents prior to using Signature Local to sign them. The signature fields are created using the Word or Excel applications. No additional software or plugins are needed, Word and Excel include the ability to add a digital signature placeholder and to verify digital signatures.

Adding a signature field to a Word Document

This section shows how to add a Microsoft Signature Line using Word 2013. The procedure is similar for Word 2003 and later versions. Adding a signature field in Excel is also similar. The “Microsoft Office Signature Line” enables a digital signature to be added to the document. The signature seals the entire document. After a document is signed, any changes to the document will invalidate its signature or signatures.

Adding the signature field

  1. Use the Insert ribbon menu and the “Add a Signature Line” icon  in the “Text” section of the ribbon.
  2. Choose “Microsoft Office Signature Line”
  3. The “Signature Setup” popup will be shown. Fill in just the “Suggested signer” field in the popup. Your SAPI program will use the “Suggested signer” value as the name of the signature field within the document. If you do not set the signer name, then Microsoft will use a guid as the field name.
  4. Click OK and the Microsoft Signature line will be added to the document. You can add more than one signature line, but they must all be added before the first person signs the document. After the document is signed by the first signer, any document modifications will invalidate the document’s existing signatures.

The Example Application

The example application requires DocuSign Signature Appliance credentials (username/password) before proceeding to upload a Word .docx file.

After supplying correct credentials, the application enables you to choose a .docx file from your file system.

A sample .docx file, “test.docx,” with one signature field is included in the source code zip archive.

After selecting and loading a file, the application lists the file’s available signature field(s). You can then select a signature field to be signed. Clicking the “sign” button will sign the selected signature field.

The signed file can then be opened in Word. Word will verify the signature(s) and ensure that the file has not been changed since it was signed.

Since digital signatures are self-contained, the recipient of a signed file does not need to install DocuSign software to verify the file’s signatures. A root certificate for the signer does need to be installed in the recipient’s Microsoft certificate trust store to enable full verification.