1

enter image description here

I have pdf file. Is there any way to set signature placeholder using docusign in that pdf file?

I am not sure what's wrong here. so I am adding fully code here. It is not allowing me to save so adding some more text.

public static EnvelopeDefinition MakeEnvelope(string signerEmail, string signerName, string signerClientId, string docPdf)
{
    byte[] buffer = System.IO.File.ReadAllBytes(docPdf);

    EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition();
    envelopeDefinition.EmailSubject = "Please sign this document";
    Document doc1 = new Document();

    string doc1b64 = Convert.ToBase64String(buffer);

    doc1.DocumentBase64 = doc1b64;
    doc1.Name = "Lorem Ipsum"; // can be different from actual file name
    doc1.FileExtension = "pdf";
    doc1.DocumentId = "3";

    envelopeDefinition.Documents = new List<Document> { doc1 };

    Signer signer1 = new Signer
    {
        Email = signerEmail,
        Name = signerName,
        ClientUserId = signerClientId,
        RecipientId = "1",
    };

    SignHere signHere1 = new SignHere
    {
        AnchorString = "/sn1/",
        AnchorUnits = "pixels",
        AnchorXOffset = "10",
        AnchorYOffset = "20",
    };

    Tabs signer1Tabs = new Tabs
    {
        SignHereTabs = new List<SignHere> { signHere1 },
    };
    signer1.Tabs = signer1Tabs;

    Recipients recipients = new Recipients
    {
        Signers = new List<Signer> { signer1 },
    };
    envelopeDefinition.Recipients = recipients;

    envelopeDefinition.Status = "sent";

    return envelopeDefinition;
}
Sami In
  • 246
  • 2
  • 11

1 Answers1

1

Yes, sure, of course. Here is an article showing how to do that and here is the relevant C# code:

https://developers.docusign.com/docs/esign-rest-api/how-to/request-signature-email-remote/

EnvelopeDefinition env = new EnvelopeDefinition();
env.EmailSubject = "Please sign this document set";

// Create document objects, one per document
Document doc1 = new Document();
string b64 = Convert.ToBase64String(Document1(signerEmail, signerName, ccEmail, ccName));
doc1.DocumentBase64 = b64;
doc1.Name = "Order acknowledgement"; // can be different from actual file name
doc1.FileExtension = "html"; // Source data format. Signed docs are always pdf.
doc1.DocumentId = "1"; // a label used to reference the doc
Document doc2 = new Document
{
    DocumentBase64 = doc2DocxBytes,
    Name = "Battle Plan", // can be different from actual file name
    FileExtension = "docx",
    DocumentId = "2",
};
Document doc3 = new Document
{
    DocumentBase64 = doc3PdfBytes,
    Name = "Lorem Ipsum", // can be different from actual file name
    FileExtension = "pdf",
    DocumentId = "3",
};

// The order in the docs array determines the order in the envelope
env.Documents = new List<Document> { doc1, doc2, doc3 };

// create a signer recipient to sign the document, identified by name and email
// We're setting the parameters via the object creation
Signer signer1 = new Signer
{
    Email = signerEmail,
    Name = signerName,
    RecipientId = "1",
    RoutingOrder = "1",
};

// routingOrder (lower means earlier) determines the order of deliveries
// to the recipients. Parallel routing order is supported by using the
// same integer as the order for two or more recipients.

// create a cc recipient to receive a copy of the documents, identified by name and email
// We're setting the parameters via setters
CarbonCopy cc1 = new CarbonCopy
{
    Email = ccEmail,
    Name = ccName,
    RecipientId = "2",
    RoutingOrder = "2",
};

// Create signHere fields (also known as tabs) on the documents,
// We're using anchor (autoPlace) positioning
//
// The DocuSign platform searches throughout your envelope's
// documents for matching anchor strings. So the
// signHere2 tab will be used in both document 2 and 3 since they
// use the same anchor string for their "signer 1" tabs.
SignHere signHere1 = new SignHere
{
    AnchorString = "**signature_1**",
    AnchorUnits = "pixels",
    AnchorYOffset = "10",
    AnchorXOffset = "20",
};

SignHere signHere2 = new SignHere
{
    AnchorString = "/sn1/",
    AnchorUnits = "pixels",
    AnchorYOffset = "10",
    AnchorXOffset = "20",
};

// Tabs are set per recipient / signer
Tabs signer1Tabs = new Tabs
{
    SignHereTabs = new List<SignHere> { signHere1, signHere2 },
};
signer1.Tabs = signer1Tabs;

// Add the recipients to the envelope object
Recipients recipients = new Recipients
{
    Signers = new List<Signer> { signer1 },
    CarbonCopies = new List<CarbonCopy> { cc1 },
};
env.Recipients = recipients;

// Request that the envelope be sent by setting |status| to "sent".
// To request that the envelope be created as a draft, set to "created"
env.Status = envStatus;

return env;
Inbar Gazit
  • 12,566
  • 1
  • 16
  • 23
  • Should I need to add all Signhere – Sami In Jul 12 '23 at 16:12
  • I have added my code in question.. can you please check it why still signature placeholder is not showing – Sami In Jul 12 '23 at 16:19
  • I don't see your code, only mine – Inbar Gazit Jul 12 '23 at 16:25
  • Please check now – Sami In Jul 12 '23 at 16:29
  • @Gazit is it visible to you now.. Also I am using embeded web so no need to send email just to update yo – Sami In Jul 12 '23 at 16:46
  • AnchorString = "/sn1/" is the issue – Inbar Gazit Jul 12 '23 at 17:18
  • Do you have the /sn1/ in your document? probably not – Inbar Gazit Jul 12 '23 at 17:18
  • Two options to fix, either you find the text in your document where you want the signature to show, replace AnchorString = "/sn1/", with AnchorString = "{TEXT}" whatever your {TEXT} is – Inbar Gazit Jul 12 '23 at 17:18
  • Or you can use fixed positioning like this: – Inbar Gazit Jul 12 '23 at 17:18
  • SignHere signHere = new SignHere(); signHere.DocumentId = "1"; signHere.PageNumber = "1"; signHere.XPosition = "191"; signHere.YPosition = "148"; – Inbar Gazit Jul 12 '23 at 17:19
  • 1
    It's working now.. Many thanks man for your all help.. – Sami In Jul 12 '23 at 18:02
  • I need your one more help.. Now once user sign the doc. Now if I want to fetch URL of that signed file then is there any way for that ? – Sami In Jul 12 '23 at 18:21
  • yes, but do you want a URL, or do you want to download the signed DOC? – Inbar Gazit Jul 12 '23 at 18:47
  • You can generate a URL the same way you did to sign, just need to do it again, can't use the same URL – Inbar Gazit Jul 12 '23 at 18:47
  • I want like once user sign that PDF then he can't sign it again.. Now that signed PDF I want to show to user in other page.. so if I can get that signed PDF URL then in that other page I can directly show.. – Sami In Jul 12 '23 at 18:49
  • Let me know if I want to download that doc then how can I do that – Sami In Jul 12 '23 at 19:28
  • Try what I suggested and see how it works – Inbar Gazit Jul 12 '23 at 20:26
  • I have tried this code to get envelop details `var apiClient = new ApiClient(basePath); apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken.access_token); var envelopesApi = new EnvelopesApi(apiClient); Envelope results = envelopesApi.GetEnvelope(clientId, "79846551-a551-4da6-87cd-589772318f9e");` but getting this error `Error calling GetEnvelope: {"errorCode":"PARTNER_AUTHENTICATION_FAILED","message":"The specified Integrator Key was not found or is disabled. Invalid account specified for user."}` – Sami In Jul 12 '23 at 21:37
  • How did you obtain the access token? and was it from the same account as the envelopeId in here? – Inbar Gazit Jul 12 '23 at 21:44
  • clientId is wrong, it should be accountId (in the GetEnvelope() call) – Inbar Gazit Jul 12 '23 at 21:44
  • OK.. I will change it.. Also I have one more question as you know I have displayed that Sign url in iframe.. so it is working fine.. But now once User sign in pdf and click on Finish button then I want to close that iframe modal.. As Finish button is redirecting back to redirect URL so how can I close that modal instead of redirecting.. Thanks – Sami In Jul 12 '23 at 21:53
  • You redirect to your own page that has JavaScript code to close the modal inside that page... – Inbar Gazit Jul 12 '23 at 22:57
  • I do that but in Iframe it is opening that same URL.. I am not sure how to close that modal.. can you please give me some guidance or example of that. – Sami In Jul 13 '23 at 11:08
  • you use window.close();? and it doesnt' close? do you get an error? – Inbar Gazit Jul 13 '23 at 16:05
  • Hi.. I manage to hide that popup.. but now I facing one issue.. it is like in pdf in Signature it is showing all old signatures done by users.. I mean if I have signed pdf and then for other company I am sending other pdf then also in that pdf that previously sign is showing to that new user.. I have added image in question for your reference.. So what I want is every time when ever new user open pdf signature field should not come with older sign.. Please let me know how can I do that.. many Thanks bro.. – Sami In Jul 13 '23 at 21:47
  • Then you have to send many envelopes, each person, send a separate envelope where you have the original clean (without any signatures) PDF as the document. – Inbar Gazit Jul 14 '23 at 04:17
  • Yes I get solved that also.. Now one more issue I get is.. I want to set Date and Title field value when user sign the pdf. But I am not sure how can I do that.. I am adding image for your reference.. In my pdf I have date and title field so when user sign pdf I want to set that valuesin PDF.. so can you please help me in that case.. Many thanks bro for your all time and help.. – Sami In Jul 14 '23 at 09:27
  • @Gazit any update for me for my last comment – Sami In Jul 14 '23 at 16:19
  • Just add a Date tab, you can do that via the API or manually – Inbar Gazit Jul 14 '23 at 16:45
  • ok.. can you please give me one example of manually if possible.. Thanks – Sami In Jul 14 '23 at 17:35
  • Date date = new Date { XPosition = "100", YPosition = "100", PageNumber = "1", DocumentId = "1" }; // Tabs are set per recipient / signer Tabs signer1Tabs = new Tabs { SignHereTabs = new List { signHere1 }, DateTabs = new List { date } }; – Inbar Gazit Jul 14 '23 at 18:25
  • ok.. and If I want to set it's value programmatically then how to do that.. like if user sign doc on 16-7-23 then I need to set date from coding side.. then how can I access it – Sami In Jul 14 '23 at 18:35
  • You cannot set the value of a Date tab, it defaults to the date/time when it was signed – Inbar Gazit Jul 14 '23 at 20:04
  • You can use a Text tab in this case – Inbar Gazit Jul 14 '23 at 20:04
  • Yes I manage it with new tabs and it's working fine.. Now I have added one more image if I want to remove that part from Envelope then is it possible.. I mean that part which is displaying `Please review & act on these document and also below that Name of account is displaying` so If I want to hide that is it possible.. I am adding image for your reference.. Thanks – Sami In Jul 17 '23 at 11:34
  • At the moment it's not possible to hide this – Inbar Gazit Jul 17 '23 at 17:05
  • Hi.. I have one question.. Is there any way I can check if document is signed or not.. I mean if I have envelope id and based on that I can check if document is signed or not.. if not signed then need to return false other wise need to return true.. – Sami In Jul 21 '23 at 18:41
  • yes, you can do that, but doing that frequently is not allowed. It's called polling. Instead you should use a webhook (Connect) to get notified when an envelope is signed. – Inbar Gazit Jul 21 '23 at 20:20