robinlu

Document Extraction with Field Validation

0 votes
I'd like to upload a PDF with fields such as [Signer1.Fullname1.Textfield1] and require that it be formatted as ###-###-###-### where # can only be a number. How do I combine these two features - document extraction, and field validation?

Reply to: Document Extraction with Field Validation

0 votes
After extracting the fields, you'd have to go back through the fields attached to each approval and set up the validation after the package has been created. Is it necessary for you to use document extraction with the fully dynamic searching of fields within the document? Or could you use your own custom named fields and use position extraction instead? If you do position extraction, you can extract the form field size and location just as document extraction does, only you specify the field in your code. By doing it this way, you can set up the field validation at the time of package creation. Position Extraction Guide - .NET SDK

- Michael

Director, Partner and Developer Technologies, OneSpan

Facebook - Twitter - LinkedIn


Reply to: Document Extraction with Field Validation

0 votes
Sure, I'm not really clear on the difference. Based on my code below, can you give me the exact field names I should have on my PDF? I'm getting fields getting created in top left corner and signature field getting created in the location of my test textbox field. Do I need brackets in field names on PDF, or not? Also, I'm trying to do this with a placeholder, not an email address, how do I do WithSigner and WithSignature for that?
DocumentPackage package = PackageBuilder.NewPackageNamed("Change Of Address 2")
                    .DescribedAs("This is the Change of Address Form 2")
                    .WithSigner(SignerBuilder.NewSignerPlaceholder(new Placeholder("Signer1")))
                    .WithDocument(DocumentBuilder.NewDocumentNamed("my document 2")
                        .FromStream(fileStream1, DocumentType.PDF)
                        .EnableExtraction()
                        .WithSignature(SignatureBuilder.SignatureFor(new Placeholder("Signer1"))
                        .WithName("sig1")
                        .WithPositionExtracted()
                        .WithField(FieldBuilder.SignatureDate())
                        .WithName("date1")
                        .WithPositionExtracted()
                        .WithField(FieldBuilder.TextField())
                        .WithName("sometextfield")
                        .WithPositionExtracted())
                        )
                    .Build();

Reply to: Document Extraction with Field Validation

0 votes
Based on your code, your form field names in your PDF should be sig1, date1, and sometextfield without any surrounding brackets. Also, if you're trying to add placeholders, your code above should be working fine. Are you running into any issues?
Haris Haidary OneSpan Technical Consultant

Reply to: Document Extraction with Field Validation

0 votes
The Click to Sign ends up in the location of the "sometextfield" field of the PDF. The Signing Date and Text Field end up in top left corner of the esignlive form.

Attachments

Reply to: Document Extraction with Field Validation

0 votes
Hi Robin, That's because you had some parentheses in your code at the wrong places. It should be the following:
DocumentPackage package = PackageBuilder.NewPackageNamed("Change Of Address 2")
                    .DescribedAs("This is the Change of Address Form 2")
                    .WithSigner(SignerBuilder.NewSignerPlaceholder(new Placeholder("Signer1")))
                    .WithDocument(DocumentBuilder.NewDocumentNamed("my document 2")
                        .FromStream(fileStream1, DocumentType.PDF)
                        .WithSignature(SignatureBuilder.SignatureFor(new Placeholder("Signer1"))
                            .WithName("sig1")
                            .WithPositionExtracted()

                            .WithField(FieldBuilder.SignatureDate()
                                .WithName("date1")
                                .WithPositionExtracted())

                            .WithField(FieldBuilder.TextField()
                                .WithName("sometextfield")
                                .WithPositionExtracted()))
                        )
                    .Build();
Haris Haidary OneSpan Technical Consultant

Reply to: Document Extraction with Field Validation

0 votes
Ok, great, document extraction is now working. Now, back to my original requirement, which is field validation. I've added validation to the textbox to validate that it is numeric. Is there any way to show the user what the expected data entry type is? There are no indicators, no text description, and the error message is generic. Also, when using Regex, it does not look like there is any masking, so the user would have a hard time knowing what data entry is expected.

Attachments

Reply to: Document Extraction with Field Validation

0 votes
You can make your textfield required and add a custom error message. This way, whenever your signer tries to sign and they've input the wrong format, your custom error message will pop-up. You can also add a pre-filled value to indicate what your signer should input.
.WithField(FieldBuilder.TextField()
                                .WithName("sometextfield")
                                .WithPositionExtracted()
                                .WithValue("Please enter a numeric value")
                                .WithValidation(FieldValidatorBuilder.Numeric()
                                    .Required()
                                    .WithErrorMessage("Please enter a numeric value")))
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