5

I have a parameter input to Text Field with html markup language or styled. But when I put tag , It doesn't show at all.

Jaspersoft supported thid Tags:

<b/>, <u/>, <i/>, <font/>,<sup/>, <sub/>, <li/>, <br/>

Is there any way to show table from that html tag ? If it can not, is there any alternative solution ?

Alex K
  • 22,315
  • 19
  • 108
  • 236
43ndr1k
  • 51
  • 1
  • 3

1 Answers1

7

There is no way to show html table's inside a textField.

The html attribute can only be used for how characters looks, not to generate layout

The only option you have is to use the jasper report HtmlComponent <hc:html/>

Example

<componentElement>
    <reportElement x="0" y="100" width="230" height="110" backcolor="#ADD8E6" uuid="332dd551-e8cd-4cb0-a11f-7325f481017b"/>
    <hc:html xmlns:hc="http://jasperreports.sourceforge.net/htmlcomponent" xsi:schemaLocation="http://jasperreports.sourceforge.net/htmlcomponent http://jasperreports.sourceforge.net/xsd/htmlcomponent.xsd" scaleType="FillFrame" horizontalAlign="Left" verticalAlign="Top">
        <hc:htmlContentExpression><![CDATA["<table><tr><td>Hello</td></tr><tr><td>World</td></tr></table>]]></hc:htmlContentExpression>
    </hc:html>
</componentElement>

The major problem with this component is that it creates an image of your html and you will have problem scaling text.

Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
  • Nice answer, Is there any solution in new version Jasper for showing text from html editor? – user_odoo Aug 28 '19 at 11:44
  • 1
    @user_odoo Thanks, no nothing has really changed, see this for further ideas https://stackoverflow.com/q/57388668/5292302. If I have time and energy I have a 1/2 idea developing a new html component using the CSSBox library to generate correct text, layout result – Petter Friberg Aug 28 '19 at 11:54
  • Thanks, Example from above link is very complicated for me I'm new in jasper. I must search how add and use Jsoup and where put public class HtmlTableDataSource. – user_odoo Aug 28 '19 at 12:13
  • 1
    @user_odoo yeah and it's far from a full html implementation (it's just a simple table example), overall jasper reports does not really support html well, I have been using the chrome engine to render pdf from a pure html report, but well this is probably even more complicated :D – Petter Friberg Aug 28 '19 at 12:25