kannansathish

Creating Signer and document dynamically during package creation

0 votes
Is there any way I can dynamically add signer and document while creating the package. For example I want to use a for loop to add no of signers(withSigner) and documents(WithDocument), when creating the package

Approved Answer

Reply to: Creating Signer and document dynamically during package creation

0 votes
Certainly. If you wanted to put in a for loop for each, you'd just create the package first, then loop through your list of signers and documents and add them. Something like:
DocumentPackage mydocpackage = newPackageNamed("mydocpackage").build();
        
        for(yourCondition){
        	mydocpackage.addSigner(newSignerWithEmail("emailaddress")
        			.withFirstName("firstname")
        			.withLastName("lastname")
        			.build());
        }
        for(yourCondition){
        	mydocpackage.getDocuments().add(newDocumentWithName("documentname")
        			.withSignature(signatureFor("emailaddress")
        					.onPage(0)
        					.atPosition(x, y))
        					.build());
        }
That should do it. Let me know if you have issues.

- Michael

Director, Partner and Developer Technologies, OneSpan

Facebook - Twitter - LinkedIn


Reply to: Creating Signer and document dynamically during package creation

0 votes
Thanks. How do I do the same(dynamically add ) for multiple signatures within the document.

Reply to: Creating Signer and document dynamically during package creation

0 votes
Adjusting the above code to create an ArrayList of Signature objects to add to your document, you could do something like this:
DocumentPackage mydocpackage = newPackageNamed("mydocpackage").build();
        
        for(yourCondition){
        	mydocpackage.addSigner(newSignerWithEmail("emailaddress")
        			.withFirstName("firstname")
        			.withLastName("lastname")
        			.build());
        }
        for(yourCondition){
        	ArrayList mysignatures = new ArrayList();
        	for(yourCondition){
        		mysignatures.add(signatureFor("emailaddress")
        				.onPage(page#)
        				.atPosition(x, y)
        				.build());
        	}
        	Document mydocument = newDocumentWithName("documentname")
        			.fromFile("myfilelocation")
        			.build();
        	mydocument.addSignatures(mysignatures);
        	mydocpackage.getDocuments().add(mydocument);
        }

- Michael

Director, Partner and Developer Technologies, OneSpan

Facebook - Twitter - LinkedIn


Reply to: Creating Signer and document dynamically during package creation

0 votes
Thanks.

Reply to: Creating Signer and document dynamically during package creation

0 votes
Not a problem! Let us know whenever you have questions. :)

- Michael

Director, Partner and Developer Technologies, OneSpan

Facebook - Twitter - LinkedIn


Reply to: Creating Signer and document dynamically during package creation

0 votes
Hi Michael I was trying to do mydocument.addSignatures(mysignatures); mydocpackage.getDocuments().add(mydocument); But this mydocpackage.getDocuments() returns HashMap values and if I try to add it will throw java.lang.UnsupportedOperationException. So I tried to do List list = new ArrayList(documentPackage.getDocuments()); list.add(mydocument); But when I run I don't see document values are populated under DocumentPackage. Can you help us on this

Reply to: Creating Signer and document dynamically during package creation

0 votes
I'm not having a problem with the code. What version of the SDK are you using?

- Michael

Director, Partner and Developer Technologies, OneSpan

Facebook - Twitter - LinkedIn


Reply to: Creating Signer and document dynamically during package creation

0 votes
SDK version 10.9 and Java version 1.6

Reply to: Creating Signer and document dynamically during package creation

0 votes
and this is what I see inside DocumentPackage class private final Map documents; public Collection getDocuments() { return this.documents.values(); }

Reply to: Creating Signer and document dynamically during package creation

0 votes
It looks to me like there was a bug in adding a document in this manner. Are you able to upgrade to the latest SDK?

- Michael

Director, Partner and Developer Technologies, OneSpan

Facebook - Twitter - LinkedIn


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