Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native: HTML Markup is removed #161

Open
redddcyclone opened this issue Oct 31, 2024 · 11 comments · Fixed by #162
Open

Native: HTML Markup is removed #161

redddcyclone opened this issue Oct 31, 2024 · 11 comments · Fixed by #162
Assignees
Labels
native Issue only does not work in native mode

Comments

@redddcyclone
Copy link

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:

  • With markup set as "none":
    image

  • With markup set as "html":
    image

  • In dev mode with markup set as "html":
    image

Am I missing something?

Thanks in advance!

@melloware
Copy link
Contributor

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

@melloware melloware added the bug Something isn't working label Oct 31, 2024
@redddcyclone
Copy link
Author

<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
Copy link
Contributor

I think that is good enough.

@melloware
Copy link
Contributor

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

@melloware melloware self-assigned this Oct 31, 2024
@melloware
Copy link
Contributor

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.

melloware added a commit that referenced this issue Oct 31, 2024
melloware added a commit that referenced this issue Oct 31, 2024
@melloware melloware added native Issue only does not work in native mode and removed bug Something isn't working labels Oct 31, 2024
@melloware melloware changed the title Text fields with markup set as HTML show up as empty on native image Native: HTML Markup is being stripped Oct 31, 2024
@melloware melloware changed the title Native: HTML Markup is being stripped Native: HTML Markup is removed Oct 31, 2024
@redddcyclone
Copy link
Author

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
Copy link
Contributor

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

@melloware
Copy link
Contributor

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

image

@melloware
Copy link
Contributor

melloware commented Nov 1, 2024

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
Copy link
Author

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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
native Issue only does not work in native mode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants