Jasperreports and PDF markup attribute

I work with Jasperrerports 3.5.1 and I have html style text that I need to print to PDF with the appropriate styles.

In the cell I want to print stylized text. I have a markup property set to "HTML". I created this sample text:

<p> <table border="0"> <tbody> <tr> <td>wewewe</td> <td>eeeee</td> </tr> <tr> <td>qwewewq</td> <td>3333333</td> </tr> </tbody> </table> </p> <p>4444</p> 

but in PDF format it prints as without formatting. You know how I can use html styles here because using tables inside cells is one of the client requests.

Thanks.

+4
source share
3 answers

I know this question is old, but JasperReports only supports a small, very small set of HTML tags for styling. The list I found from these tags:

 b br font u i sup sub li 

See here for more details.

+3
source

Firstly, I'm not sure if this matters, but make sure that the markup attribute value for your textElement in your JRXML is set to "html" (lowercase).

Secondly, the purpose of the markup attribute is to format the text using HTML, it is intended to highlight text in bold, italics, change the color or size of the font, etc. Table creation is not for this attribute.

You can create tables using standard JRXML without resorting to embedding HTML, an example is related to loading JasperReports under $ {JASPERREPORTS_HOME} / demo / samples / table

0
source

You can do something like

 <textField > <reportElement x="7" y="10" width="543" height="53"/> <textElement markup="html"> <font size="10" pdfFontName="Helvetica" isPdfEmbedded="true"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{myElementName}]]></textFieldExpression> </textField> 

Then you can pass the next line programmatically

 <p style="color:red"> <table border="0"> <tbody> <tr> <td style="border: 1px solid">wewewe</td> <td style="border: 1px solid">eeeee</td> </tr> <tr> <td style="border: 1px solid" >qwewewq</td> <td style="border: 1px solid">3333333</td> </tr> </tbody> </table> </p> <p>4444</p> 

I have not yet found how to create css to apply it using classes inside jasperreport text element.

0
source

All Articles