Line Break Formatting from a Webform

Options
Jacob_154284
Jacob_154284 Posts: 75
edited January 2020 in Questions

How do I keep the line formatting (line breaks between text) in a webform when inserting the text field into a templated Word Docx? Even though my text field contains line breaks, the text appears as one single row in the Word Docx.

Example Text field text with line breaks:

this is a test

for spacing to keep

Best Answer

Answers

  • Thomas_937381
    Thomas_937381 Posts: 196
    edited January 2020
    Options

    @Jacob_180056 If maintaining line breaks (\n) is required for your document, and the solution Jozef proposed isn't feasible, a slightly more technical approach might be:

    1. Try saving your text field as a .csv file: Text: Create text file
    2. Use Excel: Save spreadsheet to table to create a table (beware of commas in each line's text; some other rail guard may be needed here)
    3. Use Tables: Add a column, then Tables: Apply formulas to columns to add row index
    4. Use method explained in this thread to create JSON pairs (referencing row index in field name) from the data table: https://community.pushbot.com/discussion/795/create-json-from-data-table#latest
    5. Use Fields: Create fields from JSON to create distinct fields for each line break

    You'd then just need to pick a line limit and insert that number of line breaks / field references in your Word template.

  • Lucas_156486
    Options

    Hi, I was just looking for some way to keep the line breaks as well. The problem with Thomas's solution would be the dynamic number of fields that would be needed on the template file. I need to fill a small table on a Word template where it would look nicer to have the items listed one per row inside a single cell.

  • Jozef_783863
    Jozef_783863 Posts: 331 admin
    edited January 2020
    Options

    Hi @Lucas_116196,

    Thank you for upvoting the related post in Ideas.

    To clarify, the number of line breaks, and thus fields for each line, can be dynamic. Is this correct for your use case?

    Have you tried adding extra field references in the Word template? This way, if you have 10 lines, all ten references populate. If you have 2 lines, only the first two references populate.

    I recommend submitting a new Question so you can add more detail about what you are seeing and attempting to accomplish.

    Ask a Question
    https://community.pushbot.com/post/question/questions