how to put bold for certain word in textfield?

主宰稳场 提交于 2019-11-30 02:27:14
Ahamed Mustafa M

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

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.

Naim Nsco

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

Mark

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.

As an example, one of my expressions: {

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

}

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>

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!