Skip to navigation

How to create an envelope for offline signing (PDF)

View as Markdown

This topic demonstrates how to create an envelope that contains a PDF file that can be used for offline signing.

Note: To sign the envelope offline, you must set the account used for authentication as either:

Required data

Running the code in this how-to requires this data:

Data elementDescription
Document to be signedYou must provide at least one document to be signed. Document used in this how-to:
{HOST_EMAIL}A string value for the email address associated with the account which will host an In Person Signer. This value must exactly match (case-sensitive) the value shown in the host’s account profile.
{HOST_NAME}A string value for the name associated with the account which will host an In Person Signer. This value must exactly match (case-sensitive) the value shown in the host’s account profile.
{IN_PERSON_SIGNER_EMAIL}A string value for the email address of the In Person Signer.
{IN_PERSON_SIGNER_NAME}A string value for the name of the In Person Signer.
{SIGNER_EMAIL}A string value for the email address where the signer will receive a notification of the signing request.
{SIGNER_NAME}A string value for the full name of the signer.

Step 1. Log in to Docusign

To make the API call shown in this how-to, you must be logged in to Docusign.

See How to log in to Docusign from your app for details.

Step 2. Create an envelope definition

To create the envelope definition:

  • Create a document. This includes the document’s name, filepath, and ID.
  • Create your recipients. For this envelope, create an ‘in person signer’, ’signer’, and a ‘CC’ recipient. In this example, the in person signer name and email are used for the CC recipient, so that the in person signer will receive a copy of the signed document.
  • Create and assign signable fields (also known as tabs) specific to each signer within the document.
  • Set the envelope definition data, including a name, subject, message, recipients, and documents.
File file = {DOCUMENT_FILE};
URI fileURI = file.toURL();
ArrayList<DSDocument> documents = new ArrayList<>();
DSDocument document = new DSDocument.Builder()
.documentId(1)
.uri(fileURI.toString())
.name("doc1")
.build();
documents.add(document);
ArrayList<DSTab> inPersonSignerTabs = new ArrayList<>();
inPersonSignerTabs.add(
new DSTab.Builder()
.documentId(1)
.recipientId(1)
.pageNumber(1)
.xPosition(75)
.yPosition(580)
.width(50)
.height(40)
.type(DSTabType.SIGNATURE)
.build()
);
ArrayList<DSTab> signerTabs = new ArrayList<>();
signerTabs.add(
new DSTab.Builder()
.documentId(1)
.recipientId(2)
.pageNumber(1)
.xPosition(280)
.yPosition(645)
.width(50)
.height(40)
.type(DSTabType.SIGNATURE)
.build()
);
ArrayList<DSEnvelopeRecipient> recipients = new ArrayList<>();
recipients.add(
new DSEnvelopeRecipient.Builder()
.recipientId(1)
.routingOrder(1)
.hostName("{HOST_NAME}")
.hostEmail("{HOST_EMAIL}")
.signerName("{IN_PERSON_SIGNER_NAME}")
.signerEmail("{IN_PERSON_SIGNER_EMAIL}")
.type(DSRecipientType.IN_PERSON_SIGNER)
.tabs(inPersonSignerTabs)
.build()
);
recipients.add(
new DSEnvelopeRecipient.Builder()
.recipientId(2)
.routingOrder(2)
.signerName("{SIGNER_NAME}")
.signerEmail("{SIGNER_EMAIL}")
.type(DSRecipientType.SIGNER)
.tabs(signerTabs)
.build()
);
recipients.add(
new DSEnvelopeRecipient.Builder()
.recipientId(3)
.routingOrder(3)
.signerName("{IN_PERSON_SIGNER_NAME}")
.signerEmail("{IN_PERSON_SIGNER_EMAIL}")
.type(DSRecipientType.CARBON_COPY)
.build()
);
// DS: Envelope creation
DSEnvelope envelopeDefinition = new DSEnvelope.Builder()
.envelopeName("Test Envelope")
.emailSubject("Test Envelope -- Subject")
.documents(documents)
.recipients(recipients)
.build();

Step 3. Create the envelope

Next, use the definition you created in the previous step to create an envelope.

DSEnvelopeDelegate envelopeDelegate = DocuSign.getInstance().getEnvelopeDelegate();
envelopeDelegate.composeAndSendEnvelope(envelopeDefinition,
new DSComposeAndSendEnvelopeListener() {
@Override
public void onSuccess(String envelopeId, boolean isEnvelopeSent) {
Log.d("composeAndSendEnvelope","envelopeId: " + envelopeId);
}
@Override
public void onError(DSEnvelopeException exception) {
Log.e("composeAndSendEnvelope", exception.getLocalizedMessage());
}
}
);

Expected response

If your envelope creation is successful, the onSuccess method in the listener defined in the previous step will be triggered. The temporary envelope ID returned in this method can be used to start the offline signing process.

Next steps