how to put bold for certain word in textfield?

2020-05-19 06:35发布

问题:

I have for writing essay in the report. I just want to bold some text in my verse. I have put <b></b> tag in text, but it does not work.

An example of what I want is "My first name is Jason and my last name is Michael". Anybody know about this?

回答1:

Try surrounding the words you want to highlight with HTML <b></b> (bold) tags, and change the field content type to HTML



回答2:

This work good:

"<style isBold='true' pdfFontName='Helvetica-Bold'>" + $F{data} + "</style>"

for input data from datasource, or

<style isBold="true" pdfFontName="Helvetica-Bold">Bolt text</style>

only for some static text.

For Text-field set properties Markup = styled.



回答3:

I just changed Properties → Markup → HTML. It works.



回答4:

The <b> </b> tags no longer work on text fields. Make sure that 'Styled text' is enabled for the text field and put this in the field expression.

<style isBold="true" pdfFontName="Helvetica-Bold">Text to be bold...</style>

The pdfFontName can be whatever you like.

If you are making text bold that is already in a string be sure to escape the above quotes with a backslash or use single quotes.



回答5:

As an example, one of my expressions: {

"<b>"+$F{bezeichnung}+"</b>"+" ("+$F{anzahlStimmen}+" "+$R{stimmenI18N}+")"

}



回答6:

For example - first character of the word is RED

        <textField pattern="">
            <reportElement x="23" y="35" width="189" height="18" forecolor="#000000" uuid="dd8bc5b3-1dc9-4348-84c8-ff7993746830"/>
            <textElement textAlignment="Center" verticalAlignment="Middle" markup="styled">
                <font fontName="Apolonia" size="17" isBold="true"/>
            </textElement>
            <textFieldExpression><![CDATA["<style forecolor=\"red\">"+$F{L1_word}.substring(0,1)+"</style>"+$F{L1_word}.substring(1)]]></textFieldExpression>
        </textField>