Line Break Formatting from a Webform
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
-
@Jacob_180056 This is a good question because it has come up in the past.
Word: Create a Word Document currently does not support line breaks that are present within a field. If possible, we recommend placing each line item into its own field reference in the Word file template.
Related enhancement (confirmed):
https://community.pushbot.com/discussion/333/5
Answers
-
@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:
- Try saving your text field as a .csv file: Text: Create text file
- 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)
- Use Tables: Add a column, then Tables: Apply formulas to columns to add row index
- 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
- 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.
0 -
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.
0 -
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/questions0