2006 IR Open Dicussion Posted September 5, 2006 Share Posted September 5, 2006 By: Manfred Cerny - zephyrfredi Displaying Html code 2006-06-22 01:34 Hi all, I have a Problem using iReport and JR. I need to display html code in a text field object. The html content will be received through a Field. I've tried it already with the "Is styled text" attribute but this doesn't work. I would be very happy if anyone knows a solution. Thanks Fredi Link to comment Share on other sites More sharing options...
cbright Posted September 29, 2006 Share Posted September 29, 2006 Manfred;I am having the same problem. I need to display formatted HTML and RTF within a report. Were you able to find a solution?Regards,Chris Link to comment Share on other sites More sharing options...
arbitary Posted September 29, 2006 Share Posted September 29, 2006 I don't think the <input type=....> tags are supported for data fields. Atleast the samples don't show it. jasperreports-1.2.7demosamplesstyledtext Instead, you could use shapes around the data(a transperant rectangle maybe) and make it look like it is a textfield. Link to comment Share on other sites More sharing options...
nomlad Posted October 20, 2006 Share Posted October 20, 2006 yes, somewhere it is stated that Jasper reports allows you to report 'virtually any data format', well how about html? nope, it would seem that you cannot use Jasper to output your html text stored in your db - i've been tearing my hair out with this one and all I got with 1.2.4 was the text complete with all it's tags (isStyledText setting made no difference), now with version 1.2.7 it's worse, all I get is: 'net.sourceforge.jtds.jdbc.ClobImpl@faa03e' appearing instead of the text field.If anyone has any idea how to solve this I'd be delighted. Link to comment Share on other sites More sharing options...
NiPo10000 Posted November 3, 2006 Share Posted November 3, 2006 I'm not sure whether this is still open... Or whether you guys have found an acceptable work-around.But this is a feature I would very much appreciate... So if anyone has any insight I would appreciate some assistance. Here's what I've discovered so far: 1. "Is Styled Text" does work for a [very] limited set of HTML tags [see:http://jasperreports.sourceforge.net/samples/StyledTextReport.html] 2. If the text contains ANY HTML tags that aren't supported then the whole HTML file [text] is displayed with the HTML tags visible [i.e. not rendered] 3. Even when you use only the supported HTML tags, tags such as <LI>Point #1</LI> have three addition <BR/> after them resulting in excessive white space. 4. For the fun of it all the HTML tags must be Upper-Case else they are not recognized [see point #2] 5. I have simple HTML [generated by MS Word] hence plugging this little snippet of code into the expression field removes all the unrecognized HTML tags. [Modify as needed.. but there REALLY should be a better way… this is just painful :sick:] Code:/*This removes all the html tags not supported by iReports 1.2.7*/$F{document}.substring( $F{document}.indexOf( "<body lang=EN-US>" )+17, $F{document}.length() ).replaceAll( "</html>", ""«»).replaceAll("</body>",""«»).replaceAll($F{document}.substring( $F{document}.indexOf( "class=" )-1, $F{document}.indexOf( ">", $F{document}.indexOf( "class=" ) ) ),""«»).replaceAll("<p class=MsoNormal>",""«»).replaceAll("</p>",""«»).replaceAll("<div>",""«»).replaceAll("</div>",""«»).replaceAll("<b>","<B>"«»).replaceAll("</b>","</B>"«»).replaceAll("<u>","<U>"«»).replaceAll("</u>","</U>"«»).replaceAll("<i>","<I>"«»).replaceAll("</i>","</I>"«»).replaceAll("<li>","<LI>"«»).replaceAll("</li>","</LI>"«»).replaceAll("<OL>",""«»).replaceAll("</OL>",""«»).replaceAll("<span style='color:","<style forecolor='"«»).replaceAll("</span>","</style>"«»).replaceAll(" ",""«»).replaceAll("'","""«») Let me know what you have come up with so far!Happy coding NiPo.. Link to comment Share on other sites More sharing options...
eric_jama Posted January 31, 2007 Share Posted January 31, 2007 I have the same need - render HTML stored within a database field. This topic comes up quite a bit in the forums but I've not seen a definitive answer. Styled text seems too limited for general use. Anyone find a work around, solution or other options? I'm assuming the various output formats are what makes this challenging.Post edited by: eric_jama, at: 2007/01/31 04:20 Link to comment Share on other sites More sharing options...
nipo Posted April 3, 2007 Share Posted April 3, 2007 I’d like to resurrect this issue… I have a db field that contains HTML that needs to be included in a report. The ‘Is Styled Text’ only handles a very small sub-set of HTML tags and as soon as an unhandled tag is encountered rendering of the HTML fails resulting in the HTML tags being printed in the report. Does anyone have a work around?Does anyone know of any plans to incorporate full HTML support into iReport? Many thanksNigel. Link to comment Share on other sites More sharing options...
joseanep Posted May 25, 2007 Share Posted May 25, 2007 Hi! I'm with the same problem. Considering that source code HTML can contain differents tags and that it is impracticable to foresee all they, it can be easier to select in the original code tags that they are interpreted by the Jasper. What you think? Thanks!!Joseane Link to comment Share on other sites More sharing options...
codyjasperForge Posted July 5, 2007 Share Posted July 5, 2007 Right now the only workaround is to write a scriptlet to handle the formatting of HTML tags... For example: public String checkForAmps(String field){ String replacement = ""; if (field.contains("&")){ replacement += field.replaceAll("&", "& amp;" ); } else if (field.contains("<")){ replacement += field.replaceAll("<", "& lt;" ); } else if (field.contains("<&")){ replacement += field.replaceAll("<&", "& lt;& amp;" ); } else if (field.contains(">")){ replacement += field.replaceAll(">", "& gt;" ); } else if ((field.contains("&") == false) || (field.contains("<&") == false)|| (field.contains("<") == false) || (field.contains(">") == false)){ replacement += field; } return replacement; } I have this written inside of my scriptlet editor to handle returned data(from my db) that contains html. Also, there are only the options that are displayed on the /samples/styledtext demo that can be used to format html. Tags like <p> and </br> aren't supported. Note: The above bolded text is not the correct html syntax, I had to add space for it to display correctly inside of THIS forum. remove the spaces after the & and it should work fine. Link to comment Share on other sites More sharing options...
kschmitte Posted February 20, 2008 Share Posted February 20, 2008 As I also needed to show HTML which is in the DB inside a report, I have opened up a new JasperReports Enhancement Request in the Tracker: http://jasperforge.org/sf/tracker/do/viewArtifact/projects.jasperreports/tracker.feature_requests/artf3042artf3042 Regards, Kai Schmitte Link to comment Share on other sites More sharing options...
teodord Posted February 25, 2008 Share Posted February 25, 2008 Hi, A new text element attribute called "markup" was added to support embedding text snippets that contain style information in RTF of HTML format. The former isStyledText boolean attribute was deprecated and is now equivalent to markup="styled". All the modification are committed to SVN and will be part of the next release. A new sample /demo/samples/markup was added to show this new feature. Thank you,Teodor Link to comment Share on other sites More sharing options...
kschmitte Posted February 26, 2008 Share Posted February 26, 2008 Hello Teodor, thank you very much!Then I'll wait for the next release of JasperReports. Will I need to get a new JasperServer version also, or will it be sufficient to exchange the JasperReport files? Thanks! Kai Link to comment Share on other sites More sharing options...
santiagofmg Posted January 24, 2011 Share Posted January 24, 2011 hIOn version 4 of ireport has HTML support for very basic tags but TAGS like <table> are not supported. Is there a plan to support the render of html tables on IReports?. Or there's a pluggin or programatically i can do this on this version. Thanks for your help. Grettings form Ecuador....Encoding in the middle of the world ;) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now