Skip to content

Create Template

The create_template function populates a template with the values extracted from a PDF document, creating a new file with the completed values.

Parameters:

  • template_id: The ID of the template file in Blipper. This identifies the template to be used.
  • text: A dictionary containing the extracted key-value pairs from the PDF document. These values will be used to populate the template.
  • final_document_id: The name for the new file with the completed values. This will be used to identify the generated file in Blipper.

Returns:

  • A dictionary containing the ID and content of the generated file. The file_id represents the ID of the generated file, and the content represents the string with the content of the new file.

Usage:

Provide the ID of the template file (template_id) that you want to populate. Pass the dictionary containing the extracted key-value pairs from the PDF document (text). Specify a name for the new file with the completed values (final_document_id). Call the create_template method of the Blipper object, passing the template_id, text, and final_document_id as parameters.

Example:

1
2
3
4
5
6
7
8
9
from blipper import Blipper

blipper = Blipper(api_key="my_api_key")

result: dict = blipper.create_template(template_id="template.html", text=text, final_document_id="completed_template")

print(text) 

# Output: {'file_id': 'completed_template.html', 'content': '<html>...</html>'}

In this example, the template file identified by template.html is populated with the values extracted from the PDF document (text). A new file named completed_template.html is generated with the completed values. The result dictionary contains the ID (file_id) of the generated file and the string with the content of the new file (content).