-2

I have to do something like this with JasperReports:

Hello Everyone, my name is xxxxxxxxxxxx, posting a question in yyyyyy

In the above text xxxxxxxxxxxx is dynamic which is coming from database so I don't know the length of that string but the rest of the text(starting from the comma,) should be present immediately after that. There should not be any space between xxxxxxxxxxx and comma(,).

FYI:Here I am using 4 textfields.

Alex K
  • 22,315
  • 19
  • 108
  • 236
Jayanth
  • 1
  • 1
  • 2
  • add text field like this `"my name is"+$F{name}+", posting a question in "+F{year}` – Mani Deep Sep 03 '15 at 09:14
  • 1
    Thanks Mani, For the first time I tried like this only(total text taken in one TextField). But please note that the dynamic text(xxxxx..) should be in bold. In a single TextField I am unable to apply different styles. This is the reason that why I have taken in 4 separate TextFields. I tried below solution but no use.. http://stackoverflow.com/questions/16294372/use-multiple-fonts-for-a-single-text-field-in-jasper-reports Thanks. – Jayanth Sep 03 '15 at 13:09
  • Possible duplicate of [Style a text field in JasperReports](https://stackoverflow.com/questions/8135215/style-a-text-field-in-jasperreports) – Alex K Mar 24 '18 at 18:32

2 Answers2

0

Try Markup for TextField

Ex:

<!--Markup using: styled-->
<textField>
    <reportElement x="200" y="10" width="590" height="42"/>
    <textElement markup="styled"/>
    <textFieldExpression><![CDATA["The static text without any format.\nThe field's data with bold format<style isBold='true'>:Mani, here im bold</style>\n<style isBold='true' isItalic='true' isUnderline='true'>The static underlined text with bold and italic format</style>"]]></textFieldExpression>
</textField>

Here add your fields and styles as per your requirement.

for full reference on Markup for Textfield visit this SO Answer

Community
  • 1
  • 1
Mani Deep
  • 1,298
  • 2
  • 17
  • 33
0

Try creating a parameter like "name", than the expression of your textfield should be something like:

"Hello Everyone, my name is " + $P{name} + "....."

This should work.

Davi Bogo
  • 117
  • 1
  • 4
  • 15