I’m having problems with newline characters not being recognized in reports. Specifically, I am using reporting with docx as both input and output format. When a TextArea field is printed, any newline characters - which display fine on screen - are removed. The text just runs together in a big long line, evidently with no “\n” or “\r\n”.
Is there a way to fix this? Is Cuba handling these correctly?
Just to clarify… when I print a String property that was edited with a TextArea component, the report removes all the linefeeds. Persistence and screen display work fine. Same problem on Windows and OSX.
Anyone else having problems with this? Workaround?
Hi Eric,
I have tried to reproduce the problem but in my report lines are printed ok.
Could you share the report? You can get the report using the “Export” button on the Reports -> Reports screen.
Hi,
I have looked at your report and created a similar one.
Still could not reproduce the problem: new line is correctly printed on a new line.
I use the platform version 6.5.5 in my test project. Which version do you use?
Does the issue occur with both templates? Which fields should have multiple lines?
I have the same issue. The column has text type (unlimited string) and in the docx the output doesn’t print the new lines.
I have used plain SQL to retrieve data, not groovy script.
Because I didn’t find a solution (don’t know if it’s a bug or not) I have found a workaround (quite ugly though).
Instead of normal field I used inline html in the docx report as described here: [url=]https://github.com/cuba-platform/yarg/wiki/Quick-start[/url]
and so the actual field is actually replaced with a html which I built dynamically and includes tag.
For this I created a function in groovy wich splits the string by the newline character:
I am having a similar problem, new line is being identified as a space.
Thanks for this workaround,
I am not quite sure how to add this groovy script with my SQL queries which return a string with possible new lines, would you mind explaining it in a more detailed way?
Hi. The problem only occurs when the output is set to PDF. I found a workaround - add 2 space characters at the end of line, prior to the line break. That way the PDF renders properly with line feeds.
It also depends on the font and its size. Times New Roman, size 10 shows everything on a single line, while size 12 works fine. So it is font-specific…
On a second thought… I lost more than an hour playing with cell width, font name/size and db field content - the 2 spaces workaround stopped working as long as the text fit in 1 cell, so I had to remove cell merge and set cell width short enough to trigger multi line split…
Nah… it’s a PDF mess. I give up.
Ok, I got it working by implementing my own DocxFormatter (actually extending from the existing) and replacing a new line token with </w:t><w:br/><w:t> in the MainDocumentPart.