Jump to content

Leading spaces in text field


drummer54

Recommended Posts

How can I force leading spaces in a text field?  I have a report with a field for license number & state, displayed in this format:
123456789 / LA

If the individual for whom the report is being run for doesn't have this information, we want it to be printed like this:
                   /
providing room for manual entry of the license number before the slash.

However, what I get is this:
/

The expression I'm using is:
($F{license_number} != "" ? $F{license_number} + " / " + $F{issue_state} : "                    /" + $F{issue_state})

We are using JasperSoft Studio 5.5.1

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

You're probably viewing the report in html and html trims leading spaces. One solution is to display the report in pdf format.

Another is just to set Markup to "html" and to space leading spaces with " " or do something like "<span style='text-indent:10px;'>" + $F{SHIPNAME} + "</span>"

Link to comment
Share on other sites

Thanks for the response. I'm viewing the report in the JasperSoft Studio Preview pane. The leading spaces are also trimmed when the report is exported to PDF. I'm new to Jasper Reports and I noticed the Markup HTML option but honestly have grown a little weary of experimenting when it would be nice if these types of things were better documented (and that goes for most of today's software & what passes for documentation; I'm not just picking on this product). I'll give that a try. Thanks.
Link to comment
Share on other sites

Turns out the problem was my lack of familiarity with Java, which I've used very little and over 10 years ago. Here is how I had the field value defined, which returned true rather than the expected false:

($F{license_number} != "" ? $F{license_number} + " / " + $F{issue_state} : " / " + $F{issue_state})

 

Changing it to the following caused it to work correctly.

(!"".equals($F{license_number}) ? $F{license_number} + " / " + $F{issue_state} : " / " + $F{issue_state})

 

After doing this the designer wouldn't allow me to change the Markup back to none - the dropdown was empty. I had to edit the source. One of several bugs I've found with Studio. It would also be nice if I could do a right-click/copy within the expression editor but I guess that's something for another day.

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