This topic contains 4 replies, has 3 voices, and was last updated by  Duo_Liang 2 months, 1 week ago.

  • Author
    Posts
  • Participant
    nserror
    Newbie
    Member since: 11.04.2016
    Number of posts: 13

    We have a need to create a transaction entirely programmatically without displaying any type of UI. To my knowledge this is possible through the use of templates. But as far as I can ascertain, templates needed to be created by hand in advance.

    Is there a way to generate templates programmatically behind the scenes? By that I mean passing in a document and specifying coordinates / a location on a certain page to place the signature field and then being able to use that result to create a transaction and send it out without there ever needing to be human interaction?

    Thanks

    Keymaster
    Duo_Liang
    Guru
    Member since: 14.06.2018
    Number of posts: 691

    Score

    1

    Hi nserror,

    Sure, template allows you to store document at OneSpan Sign side and quickly create transactions if changes are minimal.
    Below sample code shows you how to create a template where leaves signers placeholders from scratch and send a new transaction on this template byreplacing signers with concrete recipients.

    EslClient eslClient = new EslClient(API_KEY, API_URL);
                    
                DocumentPackage template = PackageBuilder.NewPackageNamed("My template from scratch .NET SDK")
                      .WithSigner(SignerBuilder.NewSignerPlaceholder(new Placeholder("PlaceholderId1")))
                      .WithDocument(DocumentBuilder.NewDocumentNamed("doc1")
                              .FromFile("your_file_path")
                              .WithSignature(SignatureBuilder.SignatureFor(new Placeholder("PlaceholderId1"))
                                    .OnPage(0)
                                    .AtPosition(100,100))
                              )
                      .Build();
    
    
                PackageId templateId = eslClient.CreateTemplate(template);
                Debug.Print("templateId Id: " + templateId);
    
    
                DocumentPackage newPackage = PackageBuilder.NewPackageNamed("Package created from template")
                                            .WithSigner(SignerBuilder.NewSignerWithEmail("signer1@mailinator.com")
                                                    .WithFirstName("singer1 firstname")
                                                    .WithLastName("signer2 lastname")
                                                    .Replacing(new Placeholder("PlaceholderId1")))
                                           .Build();
    
    
                PackageId packageFromTemplate = eslClient.CreatePackageFromTemplate(templateId, newPackage);
                Debug.Print("packageFromTemplate Id: " + packageFromTemplate);
                eslClient.SendPackage(packageFromTemplate);

    Hope this could help!
    Duo


    Duo Liang
    OneSpan Junior Technical Evangelist
    • This reply was modified 2 months, 1 week ago by  Duo_Liang.
    Keymaster
    mwilliams
    Guru
    Member since: 21.08.2015
    Number of posts: 904

    Score

    1

    You can also do this directly without using a template, since you’re wanting to avoid the designer, the only reason to create a template would be to avoid loading the document each time.

    You can also use our extraction capabilities, like text tags, position extraction, or document extraction to place your fields and signatures in a more automated fashion than figuring out the x/y coordinates.


    – Michael
    Partner and Developer Technologies Manager, OneSpan
    Facebook – https://www.facebook.com/michael.williams1120
    Twitter – https://twitter.com/mwilliams1120
    LinkedIn – https://www.linkedin.com/in/mwilliams1120
    Participant
    nserror
    Newbie
    Member since: 11.04.2016
    Number of posts: 13

    Score

    0

    This is great information. Thank you both. May I ask, is the sample code provided above valid in version 10?

    Keymaster
    Duo_Liang
    Guru
    Member since: 14.06.2018
    Number of posts: 691

    Score

    0

    Hi nserror,

    No, unfortunately, from my knowledge, there are many design changes between v10 and v11 SDK.
    And BTW, both classic sandbox and production environments have been migrated to version 11.18.2, so you probably want to update to the corresponding SDK.

    If you want to update your SDK, I can help you with the code changes. Or you want to stick with v10 SDK, you can tell me your SDK version and I can create some sample code for you.

    Duo


    Duo Liang
    OneSpan Junior Technical Evangelist

You must be logged in to reply to this topic.