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.
DSMEnvelopeTab *tabA =
[[[[[[[DSMTabBuilder builderForType:DSMTabTypeSignHere]
addName:@"signTab"]
addRecipientId:@"1"]
addDocumentId:@"1"]
addFrame:CGRectMake(75, 580, 50, 40)]
addPageNumber:1]
build];
DSMEnvelopeTab *tabB =
[[[[[[[DSMTabBuilder builderForType:DSMTabTypeSignHere]
addName:@"signTab"]
addRecipientId:@"2"]
addDocumentId:@"1"]
addFrame:CGRectMake(280, 645, 50, 40)]
addPageNumber:1]
build];
DSMEnvelopeRecipient *recipientA = [[[[[[[[[DSMRecipientBuilder builderForType:DSMRecipientTypeInPersonSigner]
addRecipientId:@"1"]
addRoutingOrder: 1]
addHostName:@"{HOST_NAME}"]
addHostEmail:@"{HOST_EMAIL}"]
addSignerName: @"{IN_PERSON_SIGNER_NAME}"]
addSignerEmail:@"{IN_PERSON_SIGNER_EMAIL}"]
addTab:tabA]
build];
DSMEnvelopeRecipient *recipientB = [[[[[[[DSMRecipientBuilder builderForType:DSMRecipientTypeSigner]
addRecipientId:@"2"]
addRoutingOrder: 2]
addSignerName: @"SIGNER_NAME"]
addSignerEmail:@"SIGNER_EMAIL"]
addTab:tabB]
build];
DSMEnvelopeRecipient *recipientC = [[[[[[DSMRecipientBuilder builderForType:DSMRecipientTypeCC]
addRecipientId:@"3"]
addRoutingOrder: 3]
addSignerName: @"{IN_PERSON_SIGNER_NAME}"]
addSignerEmail:@"{IN_PERSON_SIGNER_EMAIL}"]
build];
NSString *fileName = @"{DOC_NAME}";
NSString *pdfFilePath = [[NSBundle bundleForClass:[self class]] pathForResource:fileName ofType:@"pdf"];
DSMEnvelopeDocument *document = [[[[[DSMDocumentBuilder builder]
addName:@"doc1"]
addDocumentId:@"1"]
addFilePath:pdfFilePath]
build];
DSMEnvelopeDefinition *envelopeDefinition = [[[[[[[DSMEnvelopeBuilder builder]
addEnvelopeName:@"Test Envelope"]
addEmailSubject:@"Test Envelope -- subject"]
addEmailMessage:@"Message blurb -- \n -- there goes the docusign email message -- sent via sdk --"]
addRecipients: @[recipientA, recipientB, recipientC]]
addDocument:document]
build];

Step 3. Create the envelope

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

[self.envelopesManager composeEnvelopeWithEnvelopeDefinition:envelopeDefinition
signingMode:DSMSigningModeOffline
completion:^(NSString * _Nullable envelopeId, NSError * _Nonnull error) {
if (error) {
NSLog(@"%@", error.localizedDescription);
return;
} else {
NSLog(@"envelope ID: %@", envelopeId);
}
}];

Expected response

If your envelope creation is successful, a temporary envelope ID is returned that can be used to start the offline signing process.

Next steps