TIBCOSoftware / jasperreports

JasperReports® - Free Java Reporting Library
https://community.jaspersoft.com/downloads/community-edition/
GNU Lesser General Public License v3.0
1.06k stars 404 forks source link

HTML List (<li>) Rendering Issue - Line Space and Indent Changed #382

Closed wayne-zhang closed 1 year ago

wayne-zhang commented 1 year ago

We upgraded JasperReports to 6.20.5 and found HTML list rendering changed. Line space increased and indent changed too (more leading space).

Based on my investigation and test, the regression is introduced in 6.20.1 when switched PDF library from iText to OpenPDF.

PDFs generated by 6.20.0 (JasperStudio 6.20.0) and 6.20.5 attached, and example template file attached too.

PDF generated by 6.20.0: Html-List-JasperReports-6 20 0

PDF generated by 6.20.5: Html-List-JasperReports-6 20 5

Report template/JRXML file (zipped)

HtmlListDemo.zip

wayne-zhang commented 1 year ago

Found what caused the list/<li/> items layout difference - JasperReports changed on how to deal with new lines (CRLF/CR/LF). Double line space fixed by remove new lines. For example, from:

<li>Item one</li> <li>Item two</li>

TO

<li>Item one</li><li>Item two</li>

Will fix the double line space issue.

Also, left indent changed too, a much big left indent added in the new release, there is no way to change it, it's an issue need to be fixed.

teodord commented 1 year ago

Your report does not use HTML markup. Your report uses "Styled Text" markup, which is our proprietary format for rich text formatting in JasperReports. Extensive work has been done starting with version 6.19.0 to improve support for bulleted and numbered lists. A number of regressions have been fixed after 6.20.0.

The problem you described about increased line spacing is not considered a bug. As you noticed, the newline characters present in the markup="styled" content are NOT ignored. If you put new line chars in the text, we'll render them. < li> tags introduce new lines themselves, just HTML does. But unlike HTML, we do NOT ignore white space.

I'm not sure I see what you mean by "much big left indent". From the screenshots above, I do not see any difference in left indent. All I can say is that many of your < li> items start with a blank character, which we do NOT ignore. You might want to remove the blank characters at the beginning of each < li> tag.