How to Display Multiline Text from JSON in PDF
I'm trying to display a list of strings from a JSON array into a PDF file using the "Set PDF Form Fields" step in Decisions. The array can contain multiple lines like a list of financial transactions. When I map it to a multi-line PDF text field, all lines are shown in a single row (e.g., Text1Text2Text3) instead of line-by-line.
Also, the PDF text field has a fixed height and can't grow dynamically. Is there a better way to display such multiline data properly in a PDF?
Comments
-
Hello!
This issue arises because PDF form fields treat plain text as a single string, and line breaks (
\n) are often not interpreted correctly. To handle dynamic multiline content, especially when the number of lines is large or varies, the recommended approach is:✅ Solution – Use HTML to PDF Rendering:
- Loop Through JSON Array:
- Use a For Each loop on your JSON array.
- Inside the loop, concatenate each line using a
<br/>tag for line breaks. - Use Create Data and Merge Text Editor steps to build a new
LineStringvariable.
- Build Final HTML:
- Merge the
LineStringinto your main HTML structure (which includes headers, footers, etc.).
- Merge the
- Generate the PDF:
- Pass the combined HTML to the HTML to PDF step. This renders the multiline content correctly with line breaks.
Example Use Case:
This method helps when dealing with a dynamic number of rows (e.g., 100+ lines), and where the PDF field cannot auto-expand.
- Loop Through JSON Array:
