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:

    1. 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 LineString variable.
    2. Build Final HTML:
      • Merge the LineString into your main HTML structure (which includes headers, footers, etc.).
    3. 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.

Sign In or Register to comment.