Design

Forms

How to include dynamic forms fields in your document?
ENTERPRISE FEATURE Available for:
Carbone Cloud
Carbone On-premise
Embedded Carbone JS
  v3.3+ 

Dynamic Text fields

Editable text fields are used to collect user-provided information. Carbone can prefill these fields.

Important Notes:

Example in LibreOffice

  1. In the top menu, click on Form > Text Box.
  2. Draw the text box on the document body.
  3. In the form toolbar, disable "Design Mode".
  4. Insert a Carbone tag inside the text box, e.g., {d.value}.
  5. Generate the document as a PDF or ODT with Carbone, and you're done!

Dynamic input example

Dynamic Checkboxes

Editable checkboxes allow users to choose between two distinct values, making them useful in complex forms and checklists. Here are several solutions:

Example 1: Clickable Checkbox in ODTs

  1. In the top menu, click on "Form" > "Check Box".
  2. Insert the check box into the ODT template.
  3. Right-click on the check box and select "Control Properties".
  4. Insert the Carbone tag in the "Name" property. The checkbox will be ticked (checked) when the value is a Boolean with the value "true," a non-empty string, a non-empty array, or a non-empty object.

Note: It is not possible to create a list of checkboxes; otherwise, an error will be returned.

Dynamic checkbox PDF ODT DOCX

Example 2: Checkbox in Any Document

Using the following expression, if the value is true, it will display ; otherwise, it will display ⬜️. Emojis can be replaced with Unicode characters.

  {d.value:ifEQ(true):show(✅):elseShow(⬜️)} // Emojies
  {d.value:ifEQ(true):show(☑):elseShow(☐)} // Unicode Characters 1
  {d.value:ifEQ(true):show(☒):elseShow(☐)} // Unicode Characters 2

Example 3: Custom checkboxes from images

This example uses dynamic images to print custom checkboxes dynamically from SVG. The following JSON dataset is used:

Data

{
  "value": false,
  "img1": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzAiIGhlaWdodD0iMzAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGc+PHJlY3Qgc3Ryb2tlPSIjMDAwIiBpZD0ic3ZnXzEiIGhlaWdodD0iMzAiIHdpZHRoPSIzMCIgeT0iMCIgeD0iMCIgZmlsbD0iIzA4ODc0RCIvPjwvZz48L3N2Zz4=",
  "img2": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzAiIGhlaWdodD0iMzAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGc+PHJlY3Qgc3Ryb2tlPSIjMDAwIiBpZD0ic3ZnXzEiIGhlaWdodD0iMzAiIHdpZHRoPSIzMCIgeT0iMCIgeD0iMCIgZmlsbD0iI0ZGRkZGRiIvPjwvZz48L3N2Zz4="
}

SVG images img2 and img1 are formatted as Data-URLs:

  1. Encode the SVG image as base64.
  2. Add the prefix data:image/svg+xml;base64, before the base64 string.

Template

In the template, insert a square placeholder image. Then, select the image and right-click > Properties > Alternative Text and write the following expression to display a colored checkbox: {d.value:ifEQ(true):show(.img1):elseShow(.img2)}.

Expression Details:

Dynamic checkbox PDF ODT DOCX