sean.garrett

PDF signature

0 votes
Hello, I have run into some problems signing PDFs: 1- I was trying to have multiple signature on the same document for the same email and I was not able to do that. The package validation was complaining. 2- I was also trying to sign a PDF document on a certain location, but I could not get it right, I extracted the position of a field using iText and then passing the position to the esign API, but it never shows it correctly. I am not sure why. 3- Is there a way to pass a field name to the API for signature, rather than its position? thank you, Sean

Reply to: PDF signature

0 votes
Hi Sean, 1 - Can you share your code? Adding multiple signatures from the same signer should be done like this:
 DocumentPackage documentPackage = newPackageNamed( "Sample Document" )
                .withSigner( newSignerWithEmail( "[email protected]" )
                        .withFirstName( "John" )
                        .withLastName( "Doe" ))
                .withDocument( newDocumentWithName( "First Document" )
                        .fromFile( "DOCUMENT_FILE_PATH" )
                        .withSignature( signatureFor( "[email protected]" )
                                .onPage( 0 )
                                .atPosition( 500, 100 )
                                .withSize( 200, 50 ) )
                        .withSignature( signatureFor( "[email protected]" )
                                .onPage( 0 )
                                .atPosition( 100, 100 )
                                .withSize( 200, 50 ) ))
                .build();
2 & 3 - With document extraction, you only have to place a field named in such a way that eSignLive may recognize it to place a signature field exactly where you want it. Hence, you can avoid using the iText library. Here is a blog that shows how to use document extraction. Although the blog is in C#/.NET, the general idea is there: https://www.silanis.com/blog/e-signlive-how-to-document-extraction-net-sdk/ Just as an FYI, document extraction will take care of 1-2-3 for you. Hope this helps :)
Haris Haidary OneSpan Technical Consultant

Reply to: PDF signature

0 votes
here is the code, below, it is pretty standard I guess. we need to use iText because of the operations around the PDF. I may be able to find a way around it, but I prefer to just send it as is if it is possible. is there a way that it can recongnize the field names just the way they are? thanks, `SignatureBuilder signatureBuilder = signatureFor(email); // if field name is not null, try to extract the // coordinates from the filed. otherwise rely on // the data in the signature to set the page and position // of the signature fields. if(fields != null && fieldName != null){ field = fields.get(signature.getFieldName()); if(field != null){ Position p = field.getPositions().get(0); signatureBuilder.onPage(p.getPage()>0?p.getPage()-1:p.getPage()); signatureBuilder.atPosition(p.getX(), p.getY()); signatureBuilder.withSize(p.getWidth(), p.getHeight()); fieldNameIsValid = true; } } // if field name did not successfully identify the // coordinates, then rely on the signature itself for // the signature coordinates and page number. if(!fieldNameIsValid){ signatureBuilder.onPage(Integer.parseInt(signature.getPageNum())); signatureBuilder.atPosition( Integer.parseInt(signature.getXCoordinate()), Integer.parseInt(signature.getYCoordinate())); } documentBuilder.withSignature( signatureBuilder); SignerBuilder signerBuilder = newSignerWithEmail( email ); signerBuilder.withCustomId(signature.getId()); signerBuilder.withFirstName(signature.getFirstName()); signerBuilder.withLastName(signature.getLastName()); packageBuilder.withSigner(signerBuilder);`

Reply to: PDF signature

0 votes
Yes, you can make it work with the fields as they are but you would have to know all the field names. For example:
 .withSignature( signatureFor( "[email protected]" )
                                .withName("sig1") )
Where sig1 is the signature form field name. With extraction enabled ( .enableExtraction() ), it will find the field. Otherwise, you would need to do .WithPositionExtracted() for each individual signature block.
Haris Haidary OneSpan Technical Consultant

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