Jump to content

Bold text and Blank when Null in PDF


prashanth.talkad

Recommended Posts

Hi,

I have two little problems here:::

1) I'm trying to <b>BOLD</b> am couple of words in a static text box as below::::

<staticText>

<reportElement x="214" y="38" width="354" height="95"

key="staticText-4"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>

<textElement textAlignment="Right" sStyledText="true">

<font/>

</textElement>

<text><![CDATA[TEXTTEXTTEXTTEXTTEXT <b>Tel +64 4 xxxxxxxxxx Email inquiries@xxxx.xxx.xx

www.xxxxxxx.xx</b>]]></text>

</staticText>

 

When I upload this report JRXML into Jasperserver, it seems to be showing the text in BOLD as it should be, but when I view the same report by exporting it to PDF format, its NOT BOLDED :blink:

 

2) I'm trying to print a salutation for a coverletter as below:

Dear Salutation FirstName LastName Suffix,

 

The problem here is that Salutation, Suffix and First Names are usually null. I've used the below JRXML to format the text when they are null.

 

<textField isStretchWithOverflow="false" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >

<reportElement

mode="Opaque"

x="73"

y="181"

width="14"

height="18"

key="textField-11"/>

<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>

<textElement>

<font/>

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[(($F{NAME_SALUTATION_DESCRIPTION}!=(null))?$F{NAME_SALUTATION_DESCRIPTION}:"")]]></textFieldExpression>

</textField>

<textField isStretchWithOverflow="false" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >

<reportElement

x="87"

y="181"

width="49"

height="18"

key="textField-15"

isRemoveLineWhenBlank="true">

<printWhenExpression><![CDATA[new Boolean($F{V_PERSON_FIRST_NAME}!=null)]]></printWhenExpression>

</reportElement>

<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>

<textElement>

<font/>

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[$F{V_PERSON_FIRST_NAME}]]></textFieldExpression>

</textField>

<textField isStretchWithOverflow="true" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >

<reportElement

x="136"

y="181"

width="118"

height="18"

key="textField-16"

stretchType="RelativeToTallestObject"/>

<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>

<textElement>

<font/>

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[(($F{V_PERSON_LAST_NAME}!=null)?$F{V_PERSON_LAST_NAME}:"")]]></textFieldExpression>

</textField>

<textField isStretchWithOverflow="false" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >

<reportElement

x="254"

y="181"

width="22"

height="18"

key="textField-17"

isRemoveLineWhenBlank="true"/>

<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>

<textElement>

<font/>

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[(($F{NAME_SUFFIX_DESCRIPTION}!=null)?$F{NAME_SUFFIX_DESCRIPTION}:"")]]></textFieldExpression>

</textField>

<textField isStretchWithOverflow="false" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >

<reportElement

x="101"

y="307"

width="24"

height="19"

key="textField-18"/>

 

Tried both the "Blank when Null" option and the "Print when Expression" terms to print a blank if value is null, but just CANNOT seem to get wide GAP that it introduces in the report. I just cant seem to format it and make it look like Dear LastName if all the rest are null. It looks like this now:

Dear ...........long white space...... LastName :blush:

 

please help !!!! :silly:

 

thanks,

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

i figured out the BOLD part of my query above.

i had not used PDF encoding. once I did that, it worked.

 

BUT, the other problem where i'm unable to truncate the white space in a line is baffling me :(( :sick:

 

 

LUCIAN, any ideas please !!!

Post edited by: prashanth.talkad, at: 2008/04/21 04:11

Link to comment
Share on other sites

Put all three fields in one text field, and concatenate their expressions

 

($F{NAME_SALUTATION_DESCRIPTION}!= null ? $F{NAME_SALUTATION_DESCRIPTION} : "") + " " +

($F{V_PERSON_FIRST_NAME} != null ? $F{V_PERSON_FIRST_NAME} : "") + " " +

($F{V_PERSON_LAST_NAME} != null ? $F{V_PERSON_LAST_NAME} : "") + " " +

($F{NAME_SUFFIX_DESCRIPTION} != null ? $F{NAME_SUFFIX_DESCRIPTION}:" ")

Link to comment
Share on other sites

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...