'Prefill PDF form field in Docusign document before sending (transform_pdf_fields == true)
I'm using the Docusign PHP SDK to create an envelope using a PDF with pre-existing form fields.
The fields are correctly being parsed by Docusign and show up on the resulting document.
However, I can't find a way to prefill some of those fields.
// Create document model
$document = new Document([
'document_base64' => $base64_content,
'name' => 'Document',
'file_extensions' => 'pdf',
'document_id' => 1, 'transform_pdf_fields' => true
]);
$signer = new Signer([
'email' => $args['client_email'],
'name' => $args['client_name'],
'recipient_id' => 1,
'routing_order' => 1,
'client_user_id' => $args['client_user_id']
]);
// This is the attempt to prefill the fields
// by using the same label as the PDF form.
// But it does nothing.
$text1 = new Text([
'tab_label' => 'field_one', 'value' => $args['client_coverage'],
]);
$text2 = new Text([
'tab_label' => 'field_two', 'value' => $args['client_term'],
]);
$signer->setTabs(new Tabs(['text_tabs' => [$text1, $text2]]));
$definition = new EnvelopeDefinition([
'email_subject' => "Please sign this document",
'documents' => [$document],
'recipients' => new Recipients(['signers' => [$signer]]),
'status' => 'sent',
]);
A call to the envelope tabs API shows the tabs in question with the exact tab label but the value is blank.
Any suggestions would be very appreciated! Thanks.
P.S. I can, after the envelope creation, get the document tabs, in order to get their IDs, and then make another request to update those.
So this is doable in 3 calls but I have a feeling that it should be possible to do in one - when the envelope is created initially.
Solution 1:[1]
@sdragnev, this can work if you use composite templates
$inline_template = new \DocuSign\eSign\Model\InlineTemplate([
'recipients' => new Recipients(['signers' => [$signer]]),
'sequence' => "1"
]);
$inline_templates = [$inline_template];
$composite_template = new \DocuSign\eSign\Model\CompositeTemplate([
'composite_template_id' => "1",
'document' => $document,
'inline_templates' => $inline_templates
]);
$composite_templates = [$composite_template];
$envelope_definition = new \DocuSign\eSign\Model\EnvelopeDefinition([
'composite_templates' => $composite_templates,
'email_subject' => "Agreement",
'status' => "sent"
]);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | IvanD |
