quarkiverse / quarkus-jasperreports

Print reports created using JasperReports using the Java API
https://community.jaspersoft.com/project/jasperreports-library
Apache License 2.0
7 stars 1 forks source link

Native: HTML Markup is removed #161

Open redddcyclone opened 1 week ago

redddcyclone commented 1 week ago

Hello all,

I'm having another problem with native image (this seems to be the last one). When I generate reports, text fields with the Markup property set as "HTML" show up as empty. No text is printed. I tried changing the same text field's markup to "none" and the text printed normally (with HTML tags visible).

This does not happen in dev mode.

I can't post the full report, but here's an example:

Am I missing something?

Thanks in advance!

melloware commented 1 week ago

can you post your JRXML report snippet? of set to HTML?

redddcyclone commented 1 week ago
<element kind="textField" uuid="b932b894-ff33-49e4-ade9-ada92f8737e2" stretchType="ElementGroupHeight" x="213" y="48" width="256" height="34" markup="html" fontName="Arial" textAdjust="StretchHeight" blankWhenNull="true" hTextAlign="Center">
    <expression><![CDATA[$F{assinatura_adicional}]]></expression>
</element>

This one or the full report?

melloware commented 1 week ago

I think that is good enough.

melloware commented 1 week ago

OK confirmed your issue with an Integration Test. Now let me see if I can fix it.

melloware commented 1 week ago

Weird its just HTML. The RTF and Styled work fine.

image

But its not throwing any errors about missing classes or unable to instantiate its just stripping tags.

redddcyclone commented 1 week ago

In my case it's not just removing the tags, the text inside them is being removed too. Also, I'm not passing a full HTML document to the text field (with <html> and so on), only a simple tag like <b>text</b>.

melloware commented 1 week ago

Yep but the same issue seems to apply its stripping all or most of the tags and sometimes the content between tags.

melloware commented 1 week ago

Here is what the Integration test looks like in Dev Mode:

image

melloware commented 1 week ago

OK debugged it the problem is here but I don't know how to fix it: https://github.com/TIBCOSoftware/jasperreports/blob/8c93395def6883f423f3b7159b2448c210e8c839/core/src/main/java/net/sf/jasperreports/engine/util/HtmlEditorKitMarkupProcessor.java#L127-L361

Jasper has this code to parse HTML and its different in Dev mode vs Native Mode.

Dev Mode:

2024-11-01 10:22:37,781 INFO  [net.sf.jas.eng.uti.HtmlEditorKitMarkupProcessor] (executor-thread-1) processElement: This is a text field element containing HTML text. HTML snippets can be used inside text elements by setting the markup attribute available for the textElement tag to html.

This is a bulleted list of fruits:applebananacherry
This is a numbered list of sports starting with number 4:footballrugbytennis
This is a lettered list of shapes starting with letter c:circleellipserectangle
Following is a numbered list of animals using Roman numerals and starting with number 3 (III):lionelephant element:BranchElement(p-implied) 505,511

2024-11-01 10:22:37,781 INFO  [net.sf.jas.eng.uti.HtmlEditorKitMarkupProcessor] (executor-thread-1) attrs: LeafElement(content) 505,510

2024-11-01 10:22:37,781 INFO  [net.sf.jas.eng.uti.HtmlEditorKitMarkupProcessor] (executor-thread-1) elementName: null
2024-11-01 10:22:37,781 INFO  [net.sf.jas.eng.uti.HtmlEditorKitMarkupProcessor] (executor-thread-1) htmlTag: content
addRun: {}
2024-11-01 10:22:37,781 INFO  [net.sf.jas.eng.uti.HtmlEditorKitMarkupProcessor] (executor-thread-1) attrs: LeafElement(content) 510,511

2024-11-01 10:22:37,781 INFO  [net.sf.jas.eng.uti.HtmlEditorKitMarkupProcessor] (executor-thread-1) elementName: null
2024-11-01 10:22:37,781 INFO  [net.sf.jas.eng.uti.HtmlEditorKitMarkupProcessor] (executor-thread-1) htmlTag: content
addRun: {net.sf.jasperreports.engine.util.JRTextAttribute(HTML_LIST_ITEM)=net.sf.jasperreports.engine.util.StyledTextListItemInfo@73932a68}
addRun: {net.sf.jasperreports.engine.util.JRTextAttribute(HTML_LIST_ITEM)=net.sf.jasperreports.engine.util.StyledTextListItemInfo@67e20629, net.sf.jasperreports.engine.util.JRTextAttribute(HTML_LIST)=[Lnet.sf.jasperreports.engine.util.StyledTextListInfo;@59575bd2}
2024-11-01 10:22:37,781 INFO  [net.sf.jas.eng.uti.HtmlEditorKitMarkupProcessor] (executor-thread-1) attrs: BranchElement(p-implied) 511,513

Same log in Native mode generates different path...

2024-11-01 14:16:47,366 INFO  [net.sf.jas.eng.uti.HtmlEditorKitMarkupProcessor] (executor-thread-1) processElement: This is a text field  element containing HTML text. HTML snippets can be used inside text elements by setting the markup attribute available for the textElement tag to html.

This is a bulleted list of fruits:applebananacherry
This is a numbered list of sports starting with number 4:footballrugbytennis
This is a lettered list of shapes starting with letter c:circleellipserectangle
Following is a numbered list of animals using Roman numerals and starting with number 3 (III):lionelephantzebra element:BranchElement(p-implied) 544,545

2024-11-01 14:16:47,366 INFO  [net.sf.jas.eng.uti.HtmlEditorKitMarkupProcessor] (executor-thread-1) attrs: LeafElement(content) 544,545

2024-11-01 14:16:47,366 INFO  [net.sf.jas.eng.uti.HtmlEditorKitMarkupProcessor] (executor-thread-1) elementName: null
2024-11-01 14:16:47,366 INFO  [net.sf.jas.eng.uti.HtmlEditorKitMarkupProcessor] (executor-thread-1) htmlTag: content
addRun: {net.sf.jasperreports.engine.util.JRTextAttribute(HTML_LIST)=[Lnet.sf.jasperreports.engine.util.StyledTextListInfo;@23daf656, net.sf.jasperreports.engine.util.JRTextAttribute(HTML_LIST_ITEM)=net.sf.jasperreports.engine.util.StyledTextListItemInfo@49ed224}
2024-11-01 14:16:47,366 INFO  [net.sf.jas.eng.uti.HtmlEditorKitMarkupProcessor] (executor-thread-1) attrs: BranchElement(p-implied) 545,547
redddcyclone commented 1 week ago

Are both elements the same in dev and native mode? Looks like on dev the word "zebra" is not present... or is this related to the bug? Weird

melloware commented 1 week ago

Yah that is what i mean this is identical integration test code. SO somewhere in here the "parser" for HTML is whacky and everything is "off" in some way.