To append whitespace in the pattern of Text field

 Hi,

         I am trying to append and print (PDF) two spaces at the end of the value of the text field to align the decimal digits properly. But I am unable to find a suitable pattern to match whitespace. I understood that space gets truncated getting printed in PDF and hence tried to use unicode character - '\\u00A0' for space. 

 

I get the below :

 

Balance

------------------

350.00 CR

          10.00

  50.00 CR

         10 CR

 

 

But  I need  :

 

Balance

------------------

350.00 CR

   10.00

  50.00 CR

   10.00

 

 

 

I tried below for a space in the  patten, but no luck.

###.## '\\u00a0';###.## CR

 

 Can anyone please guide me?

 

Thanks

Karthick

 

lingibelli's picture
Joined: May 18 2011 - 5:51am
Last seen: 11 years 8 months ago

2 Answers:

If you're trying to line those columns up in PDF, then consider breaking it into 2 fields. Align the numbers to the right so they match up perfectly. Then in the next field display "CR" or [nothing] based on whether the value is positive or negative. The second field will be left aligned.

Regards,
Matt

mdahlman's picture
33036
Joined: Mar 13 2007 - 2:43am
Last seen: 8 years 2 months ago

@mdahlman :     Thank you. That is a good idea. But as I have sequence of fields with the same setup and introducing another field changes my alignment of the template in whole, I have implemented the below option.

                 As I didnt succeed with any appropriate pattern, I appended two spaces at the end of the value with the help of ternary operator in the text expression.

TEXT FIELD EXPRESSION :  

($F{field_name}.endsWith("CR") ? $F{field_name} : $F{field_name} + "\\u00A0\\u00A0\\u00A0")



 

Happy coding

Karthick Chandran

lingibelli's picture
Joined: May 18 2011 - 5:51am
Last seen: 11 years 8 months ago
Feedback