Как сгенерировать автоматически заполненный шаблон из docusign api - PullRequest
0 голосов
/ 19 апреля 2020

У меня есть настройка шаблона в песочнице. Всякий раз, когда я хочу, чтобы меня перенаправили на demo.docusign. net и предприняли какие-то действия с PDF, он автоматически заполняет вкладки. Но мое требование - просто создать PDF без перенаправления на docusign по нажатию кнопки . Я посылаю информацию о пользователе одним нажатием кнопки в docusign, и она должна автоматически сгенерировать данные о клиентах в PDF для просмотра (черновая версия). В настоящее время он генерирует шаблон без каких-либо динамических c пользовательских данных, хотя я передаю значения. Пожалуйста, дайте мне знать, если есть какие-либо API для этого.

Заранее спасибо

1 Ответ

0 голосов
/ 19 апреля 2020

Я не совсем уверен, что понимаю, что вы пытаетесь сделать. Но звучит так, как вы хотите:

1. Удаленная подпись. Не встроенная подпись.

2. Заполните значения вкладок в шаблонах.

Вы также не указали, какой язык программирования вы использовали, поэтому я собираюсь дать вам немного C#. Вы можете найти полные примеры кода во всех языках в ссылках выше.

        // Step 1: Obtain your OAuth token
        var accessToken = RequestItemsService.User.AccessToken; // Represents your {ACCESS_TOKEN}
        var accountId = RequestItemsService.Session.AccountId; // Represents your {ACCOUNT_ID}

        // Step 2: Construct your API headers
        var config = new Configuration(new ApiClient(basePath));
        config.AddDefaultHeader("Authorization", "Bearer " + accessToken);

        // Step 3: Create Tabs and CustomFields
        // Set the values for the fields in the template
        // List item
        List colorPicker = new List
        {
            Value = "green",
            DocumentId = "1",
            PageNumber = "1",
            TabLabel = "list"
        };

        // Checkboxes
        Checkbox ckAuthorization = new Checkbox
        {
            TabLabel = "ckAuthorization",
            Selected = "true"
        };
         Checkbox ckAgreement = new Checkbox
        {
            TabLabel = "ckAgreement",
            Selected = "true"
        };

        RadioGroup radioGroup = new RadioGroup
        {
            GroupName = "radio1",
            // You only need to provide the readio entry for the entry you're selecting
            Radios = new List<Radio> { new Radio { Value = "white", Selected = "true" } }
        };

        Text includedOnTemplate = new Text
        {
            TabLabel = "text",
            Value = "Jabberywocky!"
        };

        // We can also add a new tab (field) to the ones already in the template
        Text addedField = new Text
        {
            DocumentId = "1",
            PageNumber = "1",
            XPosition = "280",
            YPosition = "172",
            Font = "helvetica",
            FontSize = "size14",
            TabLabel = "added text field",
            Height = "23",
            Width = "84",
            Required = "false",
            Bold = "true",
            Value = signerName,
            Locked = "false",
            TabId = "name"
        };

        // Add the tabs model (including the SignHere tab) to the signer.
        // The Tabs object wants arrays of the different field/tab types
        // Tabs are set per recipient/signer
        Tabs tabs = new Tabs
        {
            CheckboxTabs = new List<Checkbox> { ckAuthorization, ckAgreement },
            RadioGroupTabs = new List<RadioGroup> { radioGroup },
            TextTabs = new List<Text> { includedOnTemplate, addedField },
            ListTabs = new List<List> { colorPicker }
        };

        // Create a signer recipient to sign the document, identified by name and email
        // We're setting the parameters via the object creation
        TemplateRole signer = new TemplateRole
        {
            Email = signerEmail,
            Name = signerName,
            RoleName = "signer",
            Tabs = tabs //Set tab values
        };

        TemplateRole cc = new TemplateRole
        {
            Email = ccEmail,
            Name = ccName,
            RoleName = "cc"
        };

        // Create an envelope custom field to save our application's
        // data about the envelope
        TextCustomField customField = new TextCustomField
        {
            Name = "app metadata item",
            Required = "false",
            Show = "true", // Yes, include in the CoC
            Value = "1234567"
        };

        CustomFields cf = new CustomFields
        {
            TextCustomFields = new List<TextCustomField> { customField }
        };

        // Step 4: Create the envelope definition
        EnvelopeDefinition envelopeAttributes = new EnvelopeDefinition
        {
            // Uses the template ID received from example 08
            TemplateId = RequestItemsService.TemplateId,
            Status = "Sent",
            // Add the TemplateRole objects to utilize a pre-defined
            // document and signing/routing order on an envelope.
            // Template role names need to match what is available on
            // the correlated templateID or else an error will occur
            TemplateRoles = new List<TemplateRole> { signer, cc },
            CustomFields = cf
        };

        // Step 5: Call the eSignature REST API
        EnvelopesApi envelopesApi = new EnvelopesApi(config);
        EnvelopeSummary results = envelopesApi.CreateEnvelope(accountId, envelopeAttributes);
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...