Joemckairnes | Posts: 6

Text Anchor - multiple locations

0 votes
I have the same text in multiple locations in a document, and I want a signer to sign each of them. Using Text Anchor since there are a random number of pages. I want to place a signature block relative to the phrase “Lessor:” There may be 1 location, or 100……. How do I tell eSL to do this? I know how to do a text anchor, but how do I handle multiple locations? Do I somehow need to ‘iterate’ through the doc and place all of these blocks…..

mwilliams | Posts: 957

Reply to: Text Anchor - multiple locations

1 votes
Hey Joe, If you use a library like iText to figure out how many instances of the string in question you have, you can set up a loop to add the signature locations based on the number of occurrences you find in the document:
int occurrences = 0;
PdfReader pdfReader;
		
pdfReader = new PdfReader("PATH_TO_FILE/sampleAgreement.pdf");
for (int page = 1; page = pdfReader.getNumberOfPages(); page++)
{
        SimpleTextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
        String currentPageText;
	currentPageText = PdfTextExtractor.getTextFromPage(pdfReader, page, strategy);
	while(currentPageText.contains("Signature")){
                occurrences++;
                currentPageText = currentPageText.substring(currentPageText.indexOf("Signature") + 9);
        }
}
       
Document mydoc = DocumentBuilder.newDocumentWithName( "sampleAgreement" )
         .fromFile( "sampleTextExtractionAgreement.pdf" )
          .build();
        
for(int i=0; i

neelsp | Posts: 77

Reply to: Text Anchor - multiple locations

0 votes
Hi, Can the first loop in the above code (the one that counts # of occurrences ) be avoided? If the document is a long document then there is considerable drag on the performance. Ideally, the second loop (the one that adds signature blocks) should do it automatically since it is anyways parsing / looping through the document. please suggest how we can improve the performance, specifically for large 100+ page documents which require signature on each page. thanks Neel

sudhangi | Posts: 59

Reply to: Text Anchor - multiple locations

0 votes
Hi, As Neel mentioned in the earlier message, we have a requirement to insert signature blocks in over 100 locations for documents that have 100+ pages. When trying to do it I get the error message "504 Gateway Timeout Error". I am able to run the same code to insert around 40-50 signature blocks but once the number goes higher up it gives the timeout error. Kindly suggest. Thanks, Sudhangi

mwilliams | Posts: 957

Reply to: Text Anchor - multiple locations

0 votes
Neel, I don't think you'd be able to avoid this loop as you need to figure out how many occurrences of the text there are. You might be able to merge the second for loop into the first one to build the doc signatures as you search for instances. This might save a little time with a long document, but probably not much. Sudhangi, are you using code similar to the code above? BTW, there is new text anchor functionality coming at some point, this year, I believe. I don't know if it will solve all of your issues, but it might help. I will ask around on this to see if there is a firm date for this feature and how it might help in this situation. I will let you know when I know more. :)

mwilliams | Posts: 957

Reply to: Text Anchor - multiple locations

0 votes
Update: Still waiting to hear back. I will let you know as soon as I hear. :)

mwilliams | Posts: 957

Reply to: Text Anchor - multiple locations

0 votes
I was told that there is no known limitation to the number of anchors. Do you have any more info on this error and where it's actually happening? Could you try a static test in a document with 100 anchors and a loop that creates 100 signature locations for these anchors (skipping the iText code that finds the number of occurrences). Also, it's been requested that you try in the new sandbox: https://sandbox.esignlive.com too, to see if the same happens.

stuladhar | Posts: 27

Reply to: Text Anchor - multiple locations

0 votes
Hi Williams, I have used following lines of code to insert 2 fields (Signature field and SignatureDate field) in multiple locations. Signatures are appearing in the multiple locations but I could not insert any SignatureDate field. for (int i = 0; i occurrencesSign; i++) { mydoc.Signatures.Add(SignatureBuilder.SignatureFor("[email protected]") .WithPositionAnchor(TextAnchorBuilder.NewTextAnchor("\\s1\\") .AtPosition(TextAnchorPosition.TOPRIGHT) .WithSize(200, 50) .WithOffset(0, -40) .WithCharacter(0) .WithOccurrence(i)).Build()); } for (int i = 0; i occurrencesDate; i++) { mydoc.Fields.Add(FieldBuilder.SignatureDate() .WithPositionAnchor(TextAnchorBuilder.NewTextAnchor("\\d1\\") .AtPosition(TextAnchorPosition.TOPRIGHT) .WithSize(200, 50) .WithOffset(50, -40) .WithCharacter(0) .WithOccurrence(i)).Build()); } DocumentPackage superDuperPackage = PackageBuilder.NewPackageNamed("Text Anchor Extraction Example .NET SDK") .WithSettings(DocumentPackageSettingsBuilder.NewDocumentPackageSettings() .WithHandOverLinkHref("https://secure.anchorgeneral.com") .WithHandOverLinkText("Exit From ESignLive") .WithHandOverLinkTooltip("Exit ESignLive")) .WithSigner(SignerBuilder.NewSignerWithEmail(myEmail1) .WithFirstName("John") .WithLastName("Smith") .WithCustomId("client") .SigningOrder(1)) .Build(); superDuperPackage.Documents.Add(mydoc); PackageId packageId = eslClient.CreatePackage(superDuperPackage); eslClient.SendPackage(packageId); Can you help me solve my issue. I am using .NET SKD for my purpose. Thanks, Sumit

DougExner | Posts: 6

Reply to: Text Anchor - multiple locations

0 votes
Sumit, You’ll need something like this, as the SignatureDate needs to be associated with a specific signature:
            for (int signatureoccurence = 0; signatureoccurence  18; signatureoccurence++)
            {
                documentBuilder.WithSignature(SignatureBuilder.SignatureFor(signer1email)
                    .WithPositionAnchor(TextAnchorBuilder.NewTextAnchor("\\s1\\")
                        .AtPosition(TextAnchorPosition.TOPRIGHT)
                        .WithSize(200, 50)
                        .WithOffset(0, -40)
                        .WithCharacter(0)
                        .WithOccurrence(signatureoccurence))
                    .WithField(FieldBuilder.SignatureDate()
                        .WithPositionAnchor(TextAnchorBuilder.NewTextAnchor("\\d1\\")
                            .AtPosition(TextAnchorPosition.TOPRIGHT)
                            .WithSize(200, 50)
                            .WithOffset(50, -40)
                            .WithCharacter(0)
                            .WithOccurrence(signatureoccurence))));
            }
I’m not quite sure with your code what is happening with the signaturedates, as they aren’t associated with anything.

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