Static Documents
Static documents allow you to configure and deploy pre-published PDF documents rather than generating the PDF dynamically from a liquid template. Use static documents for PDF documents with fixed content. Such content may vary over time but, for example, would not vary based on policy details. See the Documents topic for more information on handling HTML documents and PDF documents with variable content.
Configure and Deploy Static documents
You can configure and deploy static PDF documents as part of your configuration either by including the PDF documents in Config.zip or independent of Config.zip
using the Static Documents API or through the administrator panel. Independent static documents also have an effective date associated with each document.
Use independent static documents to:
Manage some or all of your static documents independently from
Config.zip
. Adding or updating documents does not require a new deployment.Associate an effective date with each version of a static document.
Deploying static documents
You can deploy static documents using one of the following options:
- Config.zip Static Documents:
Add the PDF files to the
/products/{productName}/policy/static_documents/
directory in yourConfig.zip
file.Deploy the updated
Config.zip
.
- Independent Static Documents:
Add the PDF files to your configuration using the Static Documents API or through the administrator panel.
No deployment necessary.
Using static documents
Configure documents in policy.json and other config files as usual.
Use the expression
{{ "my_document.pdf" | render_effective_document: as_of_timestamp}}
to retrievemy_document.pdf
from your configuration, whethermy_document.pdf
was deployed as a static document or as part ofConfig.zip
. * The optionalas_of_timestamp
is a timestamp in milliseconds from unix epoch format for the effective timestamp desired. A default value of now will be used foras_of_timestamp
if omitted.If you specify the effective date, the application will: a. First look for an independent static document,
my_document.pdf
, with an effective date matching the specifiedas_of_timestamp
. b. If no matching independent static document is found, the application will look formy_document.pdf
with the static documents deployed withConfig.zip
.If you omit the effective date, the application will: a. First look for an independent static document,
my_document.pdf
, with an effective date matchingnow
. b. If no matching independent static document is found, the application will look formy_document.pdf
with the static documents deployed withConfig.zip
, without considering theas_of_timestamp
.
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 %}