how to put bold for certain word in textfield?

2020-05-19 06:24发布

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?

6条回答
Anthone
2楼-- · 2020-05-19 06:50

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.

查看更多
何必那么认真
3楼-- · 2020-05-19 06:54

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>

Result

查看更多
何必那么认真
4楼-- · 2020-05-19 06:56

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.

查看更多
乱世女痞
5楼-- · 2020-05-19 07:02

As an example, one of my expressions: {

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

}

查看更多
▲ chillily
6楼-- · 2020-05-19 07:03

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

查看更多
该账号已被封号
7楼-- · 2020-05-19 07:07

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

查看更多
登录 后发表回答