Static PDF Documents
Socotra makes it possible to add a pre-authored PDF document to a policy instead of generating one dynamically. This feature can also be used to control conditions whether a dynamic document is rendered.
Capabilities of the feature
Use different static PDFs depending on policy details
Use a static PDF or generate one dynamically depending on policy details
Update a static PDF without affecting existing policies
No special configuration needed
Option not to generate a document at all depending on policy details
Note
If the render_static_document
filter is used, the document template must not output any other content.
Usage
Add any relevant PDF files to the folder
/products/{productName}/policy/static_documents/
Configure documents in policy.json and other config files as usual
Use the expression
{{ "my_document.pdf" | render_static_document }}
in the document templateA copy of the static PDF will be saved onto the policy
To not generate a document at all if certain conditions are met:
Use the expression
{{ nil | render_static_document }}
in the document template
Example 1: Basic Static Documents
Assume a file called state_disclosure_2020.pdf
exists in /products/{productName}/policy/static_documents/
, and that policy.json
defines the following policy document:
{
"documents": [
{
"displayName": "Regulatory Disclosure",
"fileName": "state_disclosure.pdf",
"templateName": "state.disclosure.template.liquid"
}
]
}
Then, the render_static_document
call will instruct Socotra to attach the static PDF to the policy, using this code in state.disclosure.template.liquid
:
{% if policy_state contains "California" %}
{{ "state_disclosure_2020.pdf" | render_static_document }}
{% else %}
{% comment %}
HTML or another render_static_document call, as desired
{% endcomment %}
{% endif %}
Example 2: Conditional Dynamic Documents
The render_static_document
call can also be used to control whether a dynamic document is rendered. Consider case where a dynamic document should only be rendered if the policy is written in the state of California. If policy.json
defines a document as follows:
{
"documents": [
{
"displayName": "California Regulatory Disclosure",
"fileName": "state_specific_disclosure.pdf",
"templateName": "state.specific.disclosure.template.liquid"
}
]
}
Then the render_static_document
call instructs Socotra to attach the static PDF to the policy in state.specific.disclosure.template.liquid
:
{% if policy_state contains "California" %}
{% comment %} HTML of the desired dynamic document goes here: {% endcomment %}
<h1>A heading</h1>
<p>content...</p>
{% else %}
{{ nil | render_static_document }}
{% endif %}