Jump to content
We've recently updated our Privacy Statement, available here ×

Problems with HTML markup Text Fields


victorg

Recommended Posts

Hi all:

 

Since some time ago I´m successfully using Jasper for building reports that must contain some dynamically formatted text. I´m using HTML tags in Text Field values, for bolds, italics, subscripts and superscripts.

 

Obviously the Text Field property Markup is set to HTML.

 

example of some typical text values, particularly useful for chemical notation, for example, are:

 

<i>p</i>CO<sub>2</sub>

Na<sup>+</sup>

Ca<sup>++</sup>

...

 

So, the question is related to the subscripts and superscripts.

 

I expected to get this text half character below or above the baseline respectively, but also in a smaller font size.

I get them in the correct position but at the same size as regular text.

 

Is anything wrong with that?

Is it possible to obtain the sub\'s and sup\'s in smaller sizes?

 

Thanks

Victor

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

 Hi , anyone here?

 

Well, I have spent some time playing html and the only way I have found to get smaller sub/superscripts is to maniputale the font size, as follows:

 

"H<style=\"font-size:10;\"><sub>2</sub></style>O"   

 

The problem is that this is an absolute size, so I need to pass the text size to a utility function that manipulates the text value.

I know there are CSS styles for relative font sizes, like using a %, but this does not work.

 

I guess the way it works is that Jasper engine interprets the HTML code and produces a graphical output, right?, so I guess many of the HTML tags maybe are not implemented, like the relative font-size.

 

does any of you know a better solution, pls help!  thanks

 

Victor



Post Edited by victorg at 05/12/2009 19:44



Post Edited by victorg at 05/12/2009 19:50
Link to comment
Share on other sites

  • 2 weeks later...

Hi Teodor, nice to meet you. Good Job.

 

I should have given the version, you are right. I'm working with 3.0.0.

 

Initially I did not upgrade the system because I don't feel confortable with the new version of iReport.

 

Anyway I read the Release Notes for newer JasperReport engines and I did not found references to this problem, but I guess I should have tried them.

 

Can I use iReport 3.0.0 with JasperReports 3.5.x?

 

thanks

Victor

Link to comment
Share on other sites

Hi,

 

Problems related to subscript and superscript were fixed since 3.0.0. If you check the JRStyledText class you can see it declares a config property called "net.sf.jasperreports.awt.superscript.fix.enabled".

This reminds me that the problem you signaled is also related to the version of JDK that you are running on.

For example, JR 3.0.0 had a problem with subscript when running on JDK 1.4.2. What version of Java are you running on?

 

In any case, I suggest you upgrade, as these problems seem to have been fixed. I also encourage you to upgrade to the iR NetBeans version, as it is much robust and better architectured.

You can try copy the new JR 3.5.1 jar into the iR classic, and see if you get any errors. Never tried it myself. Maybe you should ask on iR forums.

 

I hope this helps.
Teodor

 

Link to comment
Share on other sites

  • 8 months later...

Hi,

Sorry to bump this old thread.

I have the same problem with subscript and superscript in iReport / JasperReports 3.7.1. Their size is OK in the iReport viewer, but when I generate a PDF document, the subscript/superscript text is too large.

See the attached images, pdf and .jrxml file for an example.

Is there anything I can do to have subscript/superscript text in the correct (smaller) size with PDF output?

Thanks,

Etienne

 

Link to comment
Share on other sites

  • 8 months later...

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