Jump to content
We've recently updated our Privacy Statement, available here ×

Bolding part of a text field


gbaldeck

Recommended Posts

 Hi, I have a text field that contains some text. I don't want to bold all of it, only part of it.

Here is the xml of the text field:

<textFieldExpression class="java.lang.String"><![CDATA[$R{statementMessage.report.label}+": "+$P{StatementMessage}]]></textFieldExpression>

Here is how I tried to do it:

<textFieldExpression class="java.lang.String"><![CDATA[<style isBold="true" pdfFontName="Helvetica-Bold">$R{statementMessage.report.label}+": "</style>+$P{StatementMessage}]]></textFieldExpression>

Notice the style tags I used. That didn't work. I've tried several other ways but none of them worked. How should I go about doing this?

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

You are moments away from a solution!  In iReport, instead of setting your expression to:

$R{statementMessage.report.label } + ": " + $P{StatementMessage}

scroll all the way down the properties screen for that field and change the "Markup" property from "None" to "Styled" and then change the expression for this field to read:

"<style isBold=\"true\">" + $R{statementMessage.report.label} + ": </style>" + $P{StatementMessage}

Remember, that's the actual expression you enter in iReport designer mode...you don't have to edit the jrxml.

But that's just the beginning of what you can do with styled markup.  See the attached jrxml file and execute it (the static text sections look impressive in Design view, but the text fields only work at runtime) to get an idea of the possibilities.  This example is slightly modified from the one I got from Matt Dahlmann, who I now consider the undisputed king of styled text knowledge (and he's also extremely helpful on this forum in other areas).

Carl

Link to comment
Share on other sites

  • 2 years later...
  • 2 years later...
  • 3 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...