rodrigo.carmona | Posts: 13

Create Package from template and adding another document to sign

0 votes

Hi!


I have some templates that define some pdf file to be filled and signed over the OSS Session.
For all of the created transaction, we are also creating a custom pdf that needs to be signed by the same Signer.
 

I've seen the other forum topic and I'm being able to create the package from templates, add the second file, but here is the issue: The second file cant be signed. Also, can't find a way to order the documents to be signed.

Is that posible? 

Thanks in advance.


Duo_Liang | Posts: 3776

Reply to: Create Package from template and adding another document to sign

0 votes

Hi rodrigo.carmona,

 

Yes, it's completely possible to create a package out of a template, then add an additional document, see below sample code:


            EslClient eslClient = new EslClient(API_KEY, API_URL);

            //Step1: create package out of template
            DocumentPackage newPackage = newPackageNamed("Create Package from Template")
                    .withSigner(newSignerWithEmail("[email protected]")
                            .withFirstName("signer1 first name")
                            .withLastName("signer1 second name")
                            .replacing(new Placeholder("28f93502-8b47-4702-b530-e3bdc2911d52")))
                    
                    .build();

            PackageId createPackageFromTemplate = eslClient.getTemplateService()
                    .createPackageFromTemplate(new PackageId("Ox49l0Ne6UYBF0gs1GmQyGM8MqM="), newPackage);

            
            //Step2: add a new document
            Document document = DocumentBuilder.newDocumentWithName("Document1")
                        .fromFile("path_to_doc")
                        .withId("Document2")
                        .withSignature(SignatureBuilder.signatureFor("[email protected]")
                                .onPage(0)
                                .atPosition(100, 100)
                                .withSize(200, 55))
                        .build();
            eslClient.uploadDocument(document, createPackageFromTemplate);
            
            //Step3: send the package
            eslClient.sendPackage(createPackageFromTemplate);

 

You can compare your existing code with above code snippet, also, could you share the template ID and a package ID where your signer can't sign, so that I can look closer into your issue?

 

Duo


rodrigo.carmona | Posts: 13

Reply to:

0 votes

Hi Duo!

The main difference between your snippet and my actual code it's I was creating the DocumentPackage like this:

private DocumentPackage createPackage(String name, Signer signer, Document document, DocumentPackageSettings settings) {
        PackageBuilder builder = PackageBuilder.newPackageNamed(name).withSigner(signer).withDocument(document).withSettings(settings).autocomplete(true);
        return builder.build();
}

Then:

PackageId packageId = client.getTemplateService().createPackageFromTemplate(new PackageId("Ug_EIC8CCV8md-Jc7PJCHkEnrx0="), documentPackage);
client.uploadDocuments(packageId, document);

The document that I'm uploading it's created on the app like this (from a file):

DocumentBuilder builder = DocumentBuilder.newDocumentWithName(name).fromStream(input, DocumentType.PDF) .withExtractionType(ExtractionType.TEXT_TAGS).enableExtraction();

The signer is created like this:

 

SignerBuilder builder = SignerBuilder.newSignerWithEmail(email).withFirstName(firstName).withLastName(lastName) .withCustomId("Signer1").withAttachmentRequirement(atteachment1Req()) .withAttachmentRequirement(attachment2Req()) .withSmsSentTo(phoneNumber); .replacing(new Placeholder("901da53c-9bd8-43ff-8b63-460a5cccd95f"));

 

And has this to locate the signature for the Signer:

signature position at document

Maybe I need to change the order or to modify my custom document creation.
Not all the use cases have to use the template.

------

The transaction that I've used is on the sandbox:
TemplateID: Ug_EIC8CCV8md-Jc7PJCHkEnrx0=
PackageID: SouOnYztjTy2RvoD6n_TPh2gPKA=

 

Thanks for your response.


Duo_Liang | Posts: 3776

Reply to: Create Package from template and adding another document to sign

0 votes

Hi rodrigo.carmona,

 

Thanks for the information, I see the reason why it happens to you. First I'd like to clarify the nature of the issue a bit:

In your template, your placeholder has role ID "901da53c-9bd8-43ff-8b63-460a5cccd95f", role Name "Signer1"

However after creating package out of this template, the Java SDK replaces all of the role ID, role Name, signer ID to "901da53c-9bd8-43ff-8b63-460a5cccd95f"

While your text tags {{esl:Signer1:Signature:size(200,50),offset(0,-20)}} is exclusively looking for Signer with role Name of "Signer1", that's why it doesn't get extracted.

 

Because it's a drawback of SDK that it can't explicitly set role name, I would suggest you to change the placeholder's role ID to "Signer1" as well, in which case I believe it will solve the issue. To notice, placeholders added via sender UI will have this UUID format role ID, while the placeholders added via Java SDK will have the same role ID and role Name:

eslClient.getPackageService().addSigner(templateId, SignerBuilder.newSignerPlaceholder(new Placeholder("Signer1")).build());             
 

If it's possible, you can create another template through UI, add the placeholder through SDK, and finish up the rest of the design back in UI. And unfortunately you may have to follow this process every time for your subsequent templates due to the role ID and Name inconsistency.

 

Duo


rodrigo.carmona | Posts: 13

Reply to: Create Package from template and adding another document to sign

0 votes

Oh! but it's good news then if I can use the Signer1 as the placeholder.
I will try this and get back to you with any news.


Thanks Duo!


rodrigo.carmona | Posts: 13

Reply to: Create Package from template and adding another document to sign

0 votes

Hi Duo!

I've do this and it's work. I was strugling a bit because I was misunderstanding this but happens to work. You can see it here in this transaction: dJU2HhLmJuzRKtrtgQybs1s5uBo=.

Now, I know there the SDK have a method to download all signed docs. Exists anyway to loop over it, one by one?

 

Thanks in advance.


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