How to add bullet point in TextField
jasper-reports, pdf
Solution
You can use styled markup.
Try to use `<li>` tag.
The sample
The jrxml file:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="bullet_sample" language="groovy" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="aa7ced41-689a-4b8d-94aa-ee79c243a7a8">
<title>
<band height="79" splitType="Stretch">
<textField>
<reportElement uuid="bf39def6-a3a7-4fa1-9e99-e488b3567974" x="159" y="31" width="100" height="20"/>
<textElement markup="styled"/>
<textFieldExpression><![CDATA["<li>Text with bullet</li>"]]></textFieldExpression>
</textField>
</band>
</title>
</jasperReport>
The result will be (via preview in iReport):
In case using field, the right expression will be:
<textField>
<reportElement x="171" y="0" width="100" height="20"/>
<textElement markup="styled"/>
<textFieldExpression><![CDATA["<li>" + $F{fieldName} + "</li>"]]></textFieldExpression>
</textField>
Note:
- You can find more info about styled text in Style a text field in JasperReports post and in Styled Text sample
Problem
I want to add bullet point to my static text and to a text field, i added style tag to the jrxml but it didn't work for me : Here's the example : TextField : ``` <textField isBlankWhenNull="true"> <reportElement uuid="cfd514bc-d1c5-4369-b10d-71042b046e37" x="11" y="0" width="400" height="12"/> <textElement/> <textFieldExpression><![CDATA[<style size="40">.</style>$F{LMSG}]]></textFieldExpression> </textField> ``` StaticText: ``` <staticText> <reportElement uuid="c1485aba-09a4-4c7b-9106-0893341f1368" x="44" y="107" width="309" height="15"/> <textElement> <font size="9"/> </textElement> <text><![CDATA[<style size="40">.</style>Je déduis cet avoir de ma commande]]></text> </staticText> ```