ashok | Posts: 14

Add signature on each page

0 votes
Hi please suggest that how we can add signature field on each page of multiple documents page using .net sdk thanks

Approved Answer
ashok | Posts: 14

Reply to: Add signature on each page

0 votes
Hi Duo Its working Thanks for your quick reply suggest me one thing that how i can put signature on bottom of page

Duo_Liang | Posts: 3776

Reply to: Add signature on each page

0 votes
Hi Ashok, Thanks for posting on our Community! I assumed that you want to put signatures on the fixed position each page? If that's the case, it varies whether you've known the number of pages of your document. If you don't know the exact number of pages, you can first upload your document then retrieve the document's metadata, its pages will be returned as an attribute. Kindly check the sample codes below I created for you on both cases.
            EslClient eslClient = new EslClient(API_KEY, API_URL);

            string signer1Email = "[email protected]";
            string signer2Email = "[email protected]";
            string document1ID = "document1";

            //1.if you know the number of pages
            int numOfPage = 18;
            PackageBuilder packageBuilder1 = PackageBuilder.NewPackageNamed("Example Package " + System.DateTime.Now)
               .WithSigner(SignerBuilder.NewSignerWithEmail(signer1Email)
                       .WithFirstName("John")
                       .WithLastName("Smith")
                       )
               .WithSigner(SignerBuilder.NewSignerWithEmail(signer2Email)
                       .WithFirstName("Marry")
                       .WithLastName("Doe"))
           ;

            DocumentBuilder documentBuilder1 = DocumentBuilder.NewDocumentNamed(document1ID)
                                                   .FromFile("your_file_path\\18pages - Copy - Copy.pdf");

            for (int curPage = 0; curPage  numOfPage ; curPage++) {
                documentBuilder1.WithSignature(SignatureBuilder.SignatureFor(signer1Email)
                    .OnPage(curPage)
                    .AtPosition(100, 100)
                    );
            }

            packageBuilder1.WithDocument(documentBuilder1);

            PackageId packageId1 = eslClient.CreatePackageOneStep(packageBuilder1.Build());
            eslClient.SendPackage(packageId1);



            //2. if you don't know the number of pages
            DocumentPackage pkg2 = PackageBuilder.NewPackageNamed("Example Package2 " + System.DateTime.Now)
               .WithSigner(SignerBuilder.NewSignerWithEmail(signer1Email)
                       .WithFirstName("John")
                       .WithLastName("Smith")
                       )
               .WithSigner(SignerBuilder.NewSignerWithEmail(signer2Email)
                       .WithFirstName("Marry")
                       .WithLastName("Doe"))
               .WithDocument(DocumentBuilder.NewDocumentNamed(document1ID)
                   .WithId(document1ID)
                   .FromFile("your_file_path\\18pages - Copy - Copy.pdf")
                )
            .Build();


            PackageId createPackageOneStep = eslClient.CreatePackageOneStep(pkg2);

            Debug.WriteLine("package id: " + createPackageOneStep);

            pkg2 = eslClient.GetPackage(createPackageOneStep);
            Document doc1 = pkg2.GetDocument(document1ID);

            Debug.WriteLine("number of pages: " + doc1.NumberOfPages);

            IList signatures = new List();
            for (int curPage = 0; curPage  doc1.NumberOfPages; curPage++)
            {
                signatures.Add(SignatureBuilder.SignatureFor(signer1Email)
                    .OnPage(curPage)
                    .AtPosition(100, 100)
                    .Build()
                    );
            }

            eslClient.ApprovalService.UpdateApprovals(pkg2, document1ID, signatures);

            eslClient.SendPackage(createPackageOneStep);
Hope this could help! Duo

Duo_Liang | Posts: 3776

Reply to: Add signature on each page

0 votes
Hey Ashok, Here's a picture for you to better understand how to locate a field: https://developer.esignlive.com/app/uploads/field-location.png And equivalent code was:
DocumentBuilder documentBuilder1.WithSignature(SignatureBuilder.SignatureFor(signer1Email)
                    .OnPage(curPage)
                    .AtPosition(0, 1030 - 30)
                    .WithSize(50,30)
                    );
Again, the size (796*1030) was based on a normal size of PDF page, please adjust to your case if you are using a different size. Or you want to calculate depending on the uploaded document, there could be some additional customized codes to do so. Duo

ashok | Posts: 14

Reply to: Add signature on each page

0 votes
Hi duo this rule did not fit on all type of documents ,sometimes its comes in middle of page ,i am attaching one pdf file here so its become tough to find its bottom y position thanks

Attachments
test-3.pdf113.75 KB
Duo_Liang | Posts: 3776

Reply to: Add signature on each page

0 votes
Hi Ashok, Try this customized function:
        public Dictionary GetPageSizeByDocId(String apiKey, String baseUrl, String packageId, String documentId)
        {
            System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

            Dictionary pageDict = new Dictionary();
            HttpClient myClient = new HttpClient();
            myClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", apiKey);
            myClient.DefaultRequestHeaders.Add("Accept", "application/json");

            var response = myClient.GetAsync(new Uri(baseUrl) + "/packages/" + packageId+"/documents/"+documentId).Result;
            JObject docJSON = JObject.Parse(response.Content.ReadAsStringAsync().Result);
            JArray pagesArray = (JArray)docJSON["pages"];
            IList pages = pagesArray.ToObject>();
            for (int curPage = 0; curPage pages.Count; curPage++)
            {
                pageDict.Add(curPage, pages[curPage]);
            }
            return pageDict;
        }
And I used this function in the #2 scenario when you first uploaded document then retrieved the metadata. Cause the height info was also returned once it's uploaded (but can't directly get with SDK):
            //2. if you don't know the number of pages
            DocumentPackage pkg2 = PackageBuilder.NewPackageNamed("Example Package2 " + System.DateTime.Now)
               .WithSigner(SignerBuilder.NewSignerWithEmail(signer1Email)
                       .WithFirstName("John")
                       .WithLastName("Smith")
                       )
               .WithSigner(SignerBuilder.NewSignerWithEmail(signer2Email)
                       .WithFirstName("Marry")
                       .WithLastName("Doe"))
               .WithDocument(DocumentBuilder.NewDocumentNamed(document1ID)
                   .WithId(document1ID)
                   .FromFile("your_file_path\\test-3 (2).pdf")
                )
            .Build();


            PackageId createPackageOneStep = eslClient.CreatePackageOneStep(pkg2);

            Debug.WriteLine("package id: " + createPackageOneStep);

            pkg2 = eslClient.GetPackage(createPackageOneStep);
            Document doc1 = pkg2.GetDocument(document1ID);

            Debug.WriteLine("number of pages: " + doc1.NumberOfPages);

            Dictionary pageSizes = GetPageSizeByDocId(API_KEY, API_URL, createPackageOneStep.Id, document1ID);

            IList signatures = new List();
            for (int curPage = 0; curPage  doc1.NumberOfPages; curPage++)
            {
                JObject pageJObject = pageSizes[curPage];
                String heightString = (String)pageJObject["height"];
                int height = Int32.Parse(heightString);
                Debug.WriteLine("current page: " + curPage + "; height: " + height);

                signatures.Add(SignatureBuilder.SignatureFor(signer1Email)
                    .OnPage(curPage)
                    .AtPosition(0, height - 30)
                    .WithSize(50, 30)
                    .Build()
                    );
            }

            eslClient.ApprovalService.UpdateApprovals(pkg2, document1ID, signatures);

            eslClient.SendPackage(createPackageOneStep);

ashok | Posts: 14

Reply to: Add signature on each page

0 votes
Hi Duo Liang thanks for your solution but its long process solution ,we can not implement it ,we will put signature on top instead of bottom due to this limitation thanks

ashok | Posts: 14

Reply to: Add signature on each page

0 votes
Hi duo tell me 2 more things 1.If user did not receive document then how we can resend them 2.If need to change anything in existing doucment then how we can update and resend them thru .net sdk thanks

Duo_Liang | Posts: 3776

Reply to: Add signature on each page

0 votes
Hi Ashok, For #1, I assumed that you meant your signer didn't receive the email notification? If that's the case, you can call:
eslClient.PackageService.NotifySigner( packageId, "[email protected]", "HELLO SIGNER" );
Which is documented in Notify Signer guide. For #2, because you can't edit a document once it's get signed, so you'd only make updates to documents before signer started to sign. If that's the case, you can first DRAFT the package (if the status other than DRAFT), guide here:
eslClient.ChangePackageStatusToDraft(packageId);		//sent to draft
then if you simply wanted to update document level attributes like document name or description, grab your document object first, do the changes and call UpdateDocumentMetadata function (or rebuilt the document object with updated info like below), which is documented in Document Management guide:
Document document = DocumentBuilder.NewDocumentNamed("Example Document")
	.WithName("Updated document name")
	.WithDescription("Updated document description")
        .Build();
eslClient.PackageService.UpdateDocumentMetadata(documentPackage, document);
but if you wanted to update anything related to signature/fields, you'd update signature/approval level instead (again, you can Grab the existing signature object, do the changes then update vs Rebuilt the object then update), which is documented in Signatures guide:
Signature updatedSignature = SignatureBuilder.CaptureFor("[email protected]")
                      .OnPage(0)
                      .AtPosition(215, 510)
                      .WithSize(300, 50)
                      .WithId(new SignatureId("signature1"))
                      .Build();

IList signatures = new List();
signatures.Add(updatedSignature);

DocumentPackage updatedPackage = client.GetPackage(packageId);
client.ApprovalService.UpdateApprovals(updatedPackage, documentId, signatures);
Hope this could help! Duo

ashok | Posts: 14

Reply to: Add signature on each page

0 votes
Hi Duo thanks again is their a way that can we put signature on dynamic position according to contents ,our content is dynamic so we can put some html tag their and according to that html tag we can put signature position

Duo_Liang | Posts: 3776

Reply to: Add signature on each page

0 votes
Hi Ashok, If you were using some tool converting html elements to a PDF, there's two methods to suggest: (1)Text Tags: so you can output some text with text tag syntax which directly tells OneSpan Sign the size, the location, the type of the fields. (2)Text Anchors: allows you to use existing texts in PDF as an anchor to locate your fields. So potentially you can use a fixed token with white font color(your background color) to locate. This method only locates the fields but not identifies the specific type. Other automation extraction methods are using PDF forms to locate fields, which includes Document Extraction and Position Extraction. Hope this could help! Duo

ashok | Posts: 14

Reply to: Add signature on each page

0 votes
Hi Duo thanks for your support suggest us one more thing that how we will put signature on multiple places ,out content comes dyanmic so we don't know that how much signature anchor comes to find and put signature their so suggest us how we can handle multiple dyanmic anchor with looping or any syntext which replace all searched anchors thanks

Duo_Liang | Posts: 3776

Reply to: Add signature on each page

0 votes
Hey Ashok, Unfortunately, for text anchors, there's no easy way to get searched numbers and then loop through all occurrences. So if your field numbers can't be determined (for example, depend on user input), it would be better that you use text tags with white font color so that every text tag can become a field. Duo

ashok | Posts: 14

Reply to: Add signature on each page

0 votes
Hi duo ok i will put white text fields but still i don't know how much such fields ,so pls suggest how i can search and put signature their pls share its code thanks

Duo_Liang | Posts: 3776

Reply to: Add signature on each page

0 votes
Hi Ashok, Sry for the confusion, let me put it in another way. I suggested that you can use the Text Tags feature in this scenario (guide here), so that you don't need extra code to specify signature/fields. Almost all types of fields are supported with text tag syntax. Duo

ashok | Posts: 14

Reply to: Add signature on each page

0 votes
Hi duo pls suggest how we will approved date their ,i have tried multiple option but did not success like {{esl:SigningDate:capture:size(100,50)}} or esl:signer1:date but did not work pls share correct opton for date thanks

Duo_Liang | Posts: 3776

Reply to: Add signature on each page

0 votes
Hi Ashok, Please try this one: {{esl:signer1:SigningDate:size(100,50)}} To note, signer1 was the Role Name of your signer and it's case sensitive (if you didn't set the role name, OneSpan Sign will trying to search the Role ID) Duo

ashok | Posts: 14

Reply to: Add signature on each page

0 votes
Hi duo these type of thing like {{esl:signer1:SigningDate:size(100,50)}} did not support by esign print driver ,pls suggest how these things will work with print driver also thanks

Duo_Liang | Posts: 3776

Reply to: Add signature on each page

0 votes
Hi Ashok, After a quick test, it seems working fine at my side. First please make sure that you already created your package with existed signer(s), then mapped signer's Role Name to the text tag. The attachments shows you what I did to both doc and pdf file. And could you tell me what type of file you were trying to print and what reader/viewer tool you were using to print it so that I can reproduce the issue?(Adobe Reader/MS Word/etc...) Duo

Attachments
4-25-1.png117.8 KB
4-25-2.png120.79 KB
ashok | Posts: 14

Reply to: Add signature on each page

0 votes
Hi duo its not working ,i am attaching my pdf screenshot here,i have sent whole pdf in email pls check and suggest what is going wrong their

Attachments
test2.png274.02 KB
ashok | Posts: 14

Reply to: Add signature on each page

0 votes
i have tried with ms word also ,i am seding it on sandbox and its did not converted sign and dates area

Attachments
Duo_Liang | Posts: 3776

Reply to: Add signature on each page

0 votes
Hi Ashok, I see that both your word and pdf files has text tags for signer with Role Name "signer1" (case sensitive), can I have a package ID of you or can you make sure that it's not "Signer1"? And for the text tags in your pdf file, here's few stuffs I'd pointed out: (0)also, please make sure that your role name is mapping correctly with your text tags (1)I saw there're spaces in the tag, so please make sure you removed them (2)Text tags can't be wrapped into two lines, otherwise doc engine won't recognize them. You can put text tags in a very small font size to avoid this. (3)If you put text tags before the under lines, once it's uploaded, there'll be gaps where the text tags stands, so it's recommended to add text tags after the under line or right on the line and add some offsets Below is an example I made for you: Hope this could help! Duo

ashok | Posts: 14

Reply to: Add signature on each page

0 votes
Hi duo Thanks first for your long support but still i did not understood that why tags did not converted in sign and date ,i have tried all small ,large caps options,removed space and extra lines but its still shown tags instead of signature and date thanks

Attachments
test-5.pdf43.62 KB
ashok | Posts: 14

Reply to: Add signature on each page

0 votes
Hi duo i have tried different different options but its still pdf not working with print driver

Attachments
test-6.pdf18.19 KB
Duo_Liang | Posts: 3776

Reply to: Add signature on each page

0 votes
Hi Ashok, After few days of investigation, it seems it's related to your font used in PDF. Some fonts can cause text information to be lost by the Print Driver. If you find that OneSpan Sign does not recognize your Text Tags, try switching the font of those tags to Arial, Courier, and Times New Roman which are 3 fonts that it never embeds in the PDF by default. Duo

Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off