jrokstad1 | Posts: 3

Using Field Injection and Signature PositionExtraction together

0 votes
Is it possible to use Field Injection and Signature Position Extraction together in the same package? I can get either to work, depending on if .EnableExtraction() is included, but not both together. Here is one of the methods attempted:
            DocumentPackage package = PackageBuilder.NewPackageNamed("Doc1")
                .WithSigner(SignerBuilder.NewSignerWithEmail(email)
                            .WithFirstName("John")
                            .WithLastName("Smith"))
                .WithDocument(DocumentBuilder.NewDocumentNamed("My Document")
                                .FromFile(docPath)
                                .EnableExtraction() //With this line injected fields do not work, and without it, Signature position extraction does not work
                                .WithInjectedField(FieldBuilder.TextField()
                                    .WithId("txt_id")
                                    .WithPositionExtracted()
                                    .WithName("txt_id")
                                    .WithValue("Test content here..."))
                                .WithSignature(SignatureBuilder.SignatureFor(email)
                                .WithName("sig1")
                                  .WithPositionExtracted()
                                  .WithField(FieldBuilder.SignatureDate()
                                  .WithName("date1")
                                  .WithPositionExtracted())))
                .Build();

            PackageId id = client.CreatePackage(package);

            client.SendPackage(id);
Thanks

Approved Answer
mwilliams | Posts: 957

Reply to: Using Field Injection and Signature PositionExtraction together

0 votes
Hey jrokstad1, When you do EnableExtraction(), you don't need to do the .WithPositionExtracted() for your injected fields since Extraction is already enabled for the document. Also, with extracted signatures, you shouldn't need the .WithSignature portion of your code either. Here is the code for building my package with extracted signature fields and injected fields both working:
DocumentPackage superDuperPackage = PackageBuilder.NewPackageNamed("Test Doc Extraction and Injected Field")
                .WithSettings(DocumentPackageSettingsBuilder.NewDocumentPackageSettings())
                    .WithSigner(SignerBuilder.NewSignerWithEmail("[email protected]")
                                .WithFirstName("MWilliams")
                                .WithLastName("Silanis")
                                .WithCustomId("Signer"))
                    .WithSigner(SignerBuilder.NewSignerWithEmail("[email protected]")
                                .WithFirstName("Michael")
                                .WithLastName("Williams")
                                .WithCustomId("Sender"))
                    .WithDocument(DocumentBuilder.NewDocumentNamed("sampleAgreement")
                                  .FromStream(fileStream1, DocumentType.PDF)
                                  .EnableExtraction()
                                  .WithInjectedField(FieldBuilder.Label()
                                        .WithName("AccountComments")
                                        .WithId("AccountComments")
                                        .WithValue("This is the value of the comments box on this document.")))
                    .Build();
Hope this helps.

jrokstad1 | Posts: 3

Reply to: Using Field Injection and Signature PositionExtraction together

0 votes
Thanks for the advice. Removing .WithPositionExtracted() from the injected fields did the trick, and helped clean up the code substantially. I received the following message when trying to send the package using your code snippet:
{"messageKey":"error.validation.sendPackage.noApprovals","packageId":null,"entity":null,"technical":null,"message":"Cannot send package without approvals.","code":400,"name":"Validation Error"}]
This did work after re-adding the .WithSignature block however. - Justen

mwilliams | Posts: 957

Reply to: Using Field Injection and Signature PositionExtraction together

0 votes
Interesting. How are you naming your signature fields in your PDF? With the eSignLive convention of [SignerId.Firstname1] and [SignerId.Firstname1.label.date] or are they named as your code says "sig1" and "date1"? If the latter, I would guess this is why simply using "EnableExtraction()" doesn't do it all for you. :)

jrokstad1 | Posts: 3

Reply to: Using Field Injection and Signature PositionExtraction together

0 votes
I used custom names for the fields (sig1 -sig8, date1 - date8, etc). I originally tried using the [Signer.Firstname] method, however this particular form has a variable number of signers added to the document, and I found that if any of these signature block placeholders was unused (didn't have a matching signer), that the package creation would fail. - Justen

mwilliams | Posts: 957

Reply to: Using Field Injection and Signature PositionExtraction together

0 votes
Great to hear that custom field names worked to get around that!

jerrade | Posts: 12

Reply to: Using Field Injection and Signature PositionExtraction together

0 votes
I am having this same problem (without the injected field). I have a pdf file with a field named "[signer1.Capture1]". When I create a package like this:
DocumentPackage documentPackage = PackageBuilder.NewPackageNamed(packageName)               
                .WithSettings(DocumentPackageSettingsBuilder.NewDocumentPackageSettings()                
                )                
                .WithSigner(SignerBuilder.NewSignerWithEmail(signerEmail)
                    .WithFirstName(signerFirstName)
                    .WithLastName(signerLastName)
                    .WithCustomId("signer1")                
                 )
                 .WithDocument(DocumentBuilder.NewDocumentNamed("doc1")                    
                    .FromStream(ms, DocumentType.PDF)
                    .EnableExtraction()                                    
                )
                .Build();
I get the "Cannot send package without approvals" error.

Duo_Liang | Posts: 3776

Reply to: Using Field Injection and Signature PositionExtraction together

0 votes
Hi jerrade, I think the feature you are using is Document Extraction(guidance), correct? For the first glance, I can't find anything incorrect with your code, so can you share your pdf and full piece of code(please remove sensitive information) here or send to [email protected] so that I can have a closer look at that? Duo

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