divakar-loganathan

Resize signature text(that appears after signing)? I tried using withSize(wt,ht)

0 votes
Hi, I'm trying to increase the text or print that appears after a signature block is signed (Eg: E-SIGNED by FirstName LastName on Date). I tried to achieve this using withSize method for the signature, but it didn't work out(the text appears to be only the standard size). I think it's not working because I'm using the signature block in a field of a form which is generated in the application. Is there an alternate way (for withSize) or any other approach to achieve this. Thank you very much in advance. Best Regards, Logan

Approved Answer

Reply to: Resize signature text(that appears after signing)? I tried using withSize(wt,ht)

1 votes
Hi Logan, First we could dive into what factor(s) actually affect the size of the signature text. Picture above shows that: the size of the signature box is the main factor, although make the signature two lines could enlarge the font size also (but not for very small signatures). So we'll still talk about how to resize your signature objects. From your description "using the signature block in a field of a form which is generated in the application", are you using Position Extraction (guide here) or Document Extraction (guide here) to locate the signatures? With these either method, it's true that you can't directly resize the signature field when package creation, but you do can update the size with another call before sending the package, here's some sample code to do so ( I used Position Extraction method):
		EslClient eslClient = new EslClient(API_KEY, API_URL);

		DocumentPackage superDuperPackage = newPackageNamed("Resize Position Extraction Signatures")
				.withSigner(SignerBuilder.newSignerWithEmail("[email protected]")
                        .withFirstName("first name")
                        .withLastName("last name")
                        .withCustomId("signer1"))
				.withDocument(newDocumentWithName("First Document")
						.fromFile(FILE_PATH)
						.withId("document1")
						.enableExtraction()
						.withSignature(signatureFor("[email protected]")
								.withName("Text1")
								.withPositionExtracted()
								.withId(new SignatureId("signature1"))
								)
						.withSignature(signatureFor("[email protected]")
								.withName("Text2")
								.withPositionExtracted()
								)
						)
				.build();

		PackageId packageId = eslClient.createPackage(superDuperPackage);
		
		DocumentPackage package1 = eslClient.getPackage(packageId);
		
		for (Signature signature : package1.getDocument("First Document").getSignatures()) {
			if(signature.getId().getId().equals("signature1")) {
				signature.setWidth(300);
				signature.setHeight(75);
			}
		}
		
		eslClient.getApprovalService().updateSignatures(package1, "document1", new ArrayList(package1.getDocument("First Document").getSignatures()));
		
		eslClient.sendPackage(packageId);
Attachment is the test PDF I was using. Hope this could help! Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Attachments
4-1-1.pdf9.8 KB

Reply to: Resize signature text(that appears after signing)? I tried using withSize(wt,ht)

0 votes
Hi Duo, Thanks for your quick reply, Yes as you stated I'm using Position Extract for the extraction of the field. Also, thanks for your sample code, I'll try to use similar logic to update the signature, before sending the package. Best Regards, Logan

Reply to: Resize signature text(that appears after signing)? I tried using withSize(wt,ht)

0 votes
Hi Duo, Thanks for your earlier response. I was able to resize successfully. I now have another requirement, for a particular form in which I position extract and create a signature block. But unfortunately, the signature block is overlapping with another field on the form(which is not a signature field, but still when the intended signature block mentioned in the previous line is signed, it overlaps the value present in this line) I have attached an sample screenshot for this, if you see the signature block is overlapping the line(solid line) and the below line (with value inspector). Is there a way to move the position of the signature block further upwards. I know we can use atPosition, but since I'm using position extract, I thought of using anything relative to the position extracted. (like an offset to the height with the position extracted) Kindly let me know if that is possible. Thank you very much in advance.

Attachments

Reply to: Resize signature text(that appears after signing)? I tried using withSize(wt,ht)

0 votes
Hi Logan, Is this the side effect of enlarging the signature field? I see the left-top corner of field was fixed when enlarging the size. Below picture shows you how the X/Y coordinates & width/height are calculated in OSS: Position extraction only brings you X,Y,Width,Height these four parameters, and there's no functions to set offsets. So I'm afraid you have to modify the Y field according to its original value. And because there's no setter for X/Y field, I used reflection mechanism in below sample code:
		DocumentPackage package1 = eslClient.getPackage(packageId);
		Document document = package1.getDocument("First Document");

		for (Signature signature : document.getSignatures()) {
			if (signature.getId().getId().equals("signature1")) {
				try {
					//step1: reset size
					signature.setWidth(300);
					signature.setHeight(75);
					
					//step2: reset y
					java.lang.reflect.Field variableName = signature.getClass().getDeclaredField("y");
					variableName.setAccessible(true);
					variableName.set(signature, signature.getY() - 25);
				} catch (NoSuchFieldException e) {
					e.printStackTrace();
				} catch (SecurityException e) {
					e.printStackTrace();
				} catch (IllegalArgumentException e) {
					e.printStackTrace();
				} catch (IllegalAccessException e) {
					e.printStackTrace();
				}
			}
		}

		eslClient.getApprovalService().updateSignatures(package1, "document1", new ArrayList(document.getSignatures()));
(If you don't want to use reflection, you can also rebuilt the signature object by passing in all of its original field values, main task was to loop through all fields under the signature.) If you have the control of your PDF generator application, you can also consider directly enlarge and adjust location of form which is more straight-forward than adjusting metadata after position extraction was applied. Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: Resize signature text(that appears after signing)? I tried using withSize(wt,ht)

0 votes
Duo, Thanks for your quick response. I'll try this out and let you know. Cheers, Logan

Reply to: Resize signature text(that appears after signing)? I tried using withSize(wt,ht)

0 votes
Hi Duo, I tried the reflection method, it worked fine. Thank you very much once again. Best Regards, Logan

Attachments

Reply to: Resize signature text(that appears after signing)? I tried using withSize(wt,ht)

0 votes
Glad to help! :)

Duo Liang OneSpan Evangelism and Partner Integrations Developer


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