How to you change the markup value for a text elem

2019-08-29 11:41发布

I am using DynamicJasper to generate reports from some tables at run time. I have some fields that the data has been styled using basic html tags as the data was created. Very basic tags like bold and italic, and jasper reports can handle them by setting the markup attribute of the textElement to html. The problem is a can not find a way to change it using DynamicJasper.

I have tried using addFieldProperty("markup", "html") found in ColumnBuilder, but that adds markup as a property to the field markup (probably obvious that it should do that based on the name) instead of the text elemennt.

How to you change the markup value for a text element using DynamicJasper?

1条回答
The star\"
2楼-- · 2019-08-29 11:44

The DynamicJasper API does not contain methods to set markup.

But you can use JasperReports API for this needs. For example, the JRBasePrintText class and JRCommonText interface have method for setting markup:

public void setMarkup(java.lang.String markup)

The JRCommonText interface has constant fields:

public static final String MARKUP_NONE = "none";
public static final String MARKUP_STYLED_TEXT = "styled";
public static final String MARKUP_HTML = "html";
public static final String MARKUP_RTF = "rtf";

You can modify DynamicJasper classes for your needs like in this post, for example.

查看更多
登录 后发表回答