derek Posted November 24, 2008 Share Posted November 24, 2008 Hi there,Just wondering if anyone knows how to support html table input in a text field specified as "isStyledText". such as <table> <tr> <td>aaaa</td> <td>bbbb</td> </tr> </table> In Jasper Report version 2.0.4, there seemed to have attempt to support html table tags such as <table> <th> <tr> <td>, but related code was not further developed, and was removed from later version (e.g. 3.0.0) . Is it a just temporary design decision? Otherwise, can anyone suggest a way to generate a report automatically based on html table input? any prompt help will be appreciated.Cheers,DerekPost Edited by derek wang at 11/24/08 22:06 Link to comment Share on other sites More sharing options...
chris_andre Posted November 24, 2008 Share Posted November 24, 2008 Derek, What do you mean by "generate a report automatically based on html table input"? If you mean you want to pass an HTML file to your application as a datasource, have you thought about using the XML query executor? Indeed, if your HTML document is not too complex and well-formated, it should look like a XML document. You then just need to indicate the XPath query to retrieve the information stored in your table. Kind regards, Chris Link to comment Share on other sites More sharing options...
derek Posted November 24, 2008 Author Share Posted November 24, 2008 Hi Chris,Thanks for your reply. I got a content planning engine that is capable of generating dynamic html content that contains arbitury tablular data with schema determined at run time. the structure of the tables is not complex though. But what I would like to do is to take that html tabular content as input , feed into a particular text field in in Jasper report., it would be nice if Jasper Report can recognise or understand the html table input and render the tabular conent accordingly. Since I don't know the dynamic data schema before hand, parsing the HTML would be at HTML tag level, eg. <th> <tr> <td>. Would this be different situation if I understand what you suggested, that is, rendering xml data source such as <lastname>...</lastname><firstname>..</firstname>. and I don't really want to allow the user to control the look& feel of these tables, so it would be nice to just generate the report automatically (programatically), so I don't have to, for example, go into iReport to design the tables, do you see it feasible? if so, can anyone suggest how?Post Edited by derek wang at 11/24/08 22:50 Link to comment Share on other sites More sharing options...
C-Box Posted November 25, 2008 Share Posted November 25, 2008 Hi, this is not (yet) possible, but I would like that feature too. We do have customers, who want to edit table like contents within a HtmlTextArea. Now we don't allow table tags as JasperReports doesn't support them - so we simply remove them when and just allow the few supported of StyledText.When I remember right, Teodor told me some months ago, that this is very difficult to implement in point of page-breaks and floating behaviour of textelements.Perhaps Teodor or Lucian could put their comments towards that topic in todays point of view!?!? just my two centsC-Box Link to comment Share on other sites More sharing options...
derek Posted November 26, 2008 Author Share Posted November 26, 2008 Agree, it seems to be reasonable to take piece of information that already has some representation logic specified, in whatever format, and turn it into something Jasper Report can understand and process. Well, I am trying to find out: how to programaticaly generate Jasper Report from something like this: <th><td>column1</td> <td>column2</td></th> <tr> <td>aaaa</td> <td>bbbb</td> </tr>Can anyone help on this? DerekPost Edited by derek wang at 11/26/08 04:39 Link to comment Share on other sites More sharing options...
derek Posted December 3, 2008 Author Share Posted December 3, 2008 It seems to be a pending issue then, no solution has been identified so far. Teodor, Lucian? Any suggestion? Link to comment Share on other sites More sharing options...
tduffey Posted February 11, 2009 Share Posted February 11, 2009 Bump...any thoughts on this from the developers? Link to comment Share on other sites More sharing options...
Teodor Danciu Posted February 12, 2009 Share Posted February 12, 2009 Hi,I just want to reiterate what I said before when asked about this.You have to remember that the styled text feature and the more recent markup feature are all about a text field content.I repeat: a text field.So it is about formatted text. Not about layout. You can only change the attributes of text characters that still flow like a single phrase. You cannot arrange them in cells, or frames, or whatever. Or even include images for that matter. Remember: it is a single text field there, in which the different words might have different colors or font size. Nothing more. Now, what you want is a new component. A component that would be able to behave like a browser control. Being able to render any HTML. It is like putting a little InternetExpolorer or Fireforx window in your report.Sure, this is possible. Is just that you'll need to leverage the custom compoent support that now exists in JasperReports and come up with such a visual component for JasperReports.So far we have done some POC custom components for creating Flash charts and things like that (look into the JR samples), but only the sky is the limit into what future components could do.We'd love to see custom components coming in as contributions to the project in the future.The support for custom components is the greates new feature that came into JR in recent years. So far is not yet leveraged by the community. Thank you,Teodor Link to comment Share on other sites More sharing options...
derek Posted February 12, 2009 Author Share Posted February 12, 2009 Hi Teodord,Many thanks for your reply. I understand your concern regarding a separation of layout and formatted text in the text field, If the decision was merely made to avoid a high degree of uncertainty and complexity involved in the potential layout, that' s fine, and is fair enough. However, in my opinion, this separation can never be achieved: For a reporting tool, at the end of day, all you have to do is to render some information you take from somewhere else, which could contain anything including formatted text and layout. You may or may not be able to separate them. Such input information could come from anywhere else outside Jasper, including output from another reporting tool. Yes, you can define contraints and preconditions in Jasper and ask for pure formatted text, but doing so would also mean that you exclude things that could have been consolidated in Jasper. What could be better is , take the information, try to understand it, process it according to local difinition, change something, add some extra bits and pieces, and render them beautifully. If the input, in this case, the html/ xml tabular data (you don't have to see it as a layout anyway), is a reasonable way of data capturing, and the cost of processing it is acceptable, I would think it would justfy a different design decision. The concept of component you introduced seems to be very interesting to explore, I did not know anything about it. Can you tell us a bit more and shed a light on how it can be integrated? Many thanks. Cheers,DerekPost Edited by derek wang at 02/12/09 11:11 Link to comment Share on other sites More sharing options...
tduffey Posted February 12, 2009 Share Posted February 12, 2009 I agree it's about formatted text and our particular use case of needing tables meshes with that idea quite well. Our Jasper Reports are templates and the users fill in the details through the web. While filling out these details they want to make some text bold and create simple lists and tables. We're not looking to embed the full capabilities of a browser inside. Would it be possible to write a component that would extend the existing styled text feature to handle simple tables? Link to comment Share on other sites More sharing options...
bdrnotixia.com Posted September 16, 2009 Share Posted September 16, 2009 Hi, I have a "similar" problem. I need to generate pdf documents where the user can set some description field (textfield) with html text. Is it possible to do that. I try to set IsStyledText="true" on TextElement but I didn't notice any difference on the result. I still see the tags instead of the "redered results"... This is the html that I want to render: Code:<html> <head> </head> <body> 12 <ul> <li> Test 144 </li> <li> 3232 </li> <li> 3232323 </li> <li> 2322 </li> <li> 4434343 </li> </ul> <p> </p> </body></html> Link to comment Share on other sites More sharing options...
Teodor Danciu Posted September 21, 2009 Share Posted September 21, 2009 Hi, You should try markup="html" for your text field. I hope this helps.Teodor Link to comment Share on other sites More sharing options...
santiagovn Posted February 21, 2011 Share Posted February 21, 2011 Post Edited by santiagovn at 02/21/2011 17:14 Link to comment Share on other sites More sharing options...
efrendeveloper Posted September 27, 2013 Share Posted September 27, 2013 hello I have a problem, I need to print html content-enriched with Tables in there some way I have tried not interpreted texfield and HTMLComponent component shown me well but I can not grow the runtime component if the content is greater that the size of the component automatically grow there any way thank you for your <?xml version="1.0" encoding="UTF-8"?><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report1" language="groovy" printOrder="Horizontal" pageWidth="595" pageHeight="842" whenNoDataType="BlankPage" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="c4a41665-ccf7-4bc4-a013-2e0b67d74bcd"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false"> <defaultValueExpression><![CDATA["C:\Documents and Settings\Efren\Mis documentos\"]]></defaultValueExpression> </parameter> <queryString> <![CDATA[sELECT obs.`Clave` AS obs_Clave, obs.`Observa` AS obs_Observa, obs.`Importe` AS obs_ImporteFROM `obs` obs where Clave = 5]]> </queryString> <field name="obs_Clave" class="java.lang.Integer"/> <field name="obs_Observa" class="java.lang.String"/> <field name="obs_Importe" class="java.lang.Double"/> <title> <band height="79" splitType="Stretch"> <image> <reportElement uuid="f10b5a4c-01d8-47f1-9411-0abc5624015d" x="511" y="0" width="44" height="50"/> <imageExpression><![CDATA["C:\Documents and Settings\Escudo.jpg"]]></imageExpression> </image> <image> <reportElement uuid="d7df3a20-1d70-4f57-a348-00253bd48421" x="16" y="11" width="100" height="50"/> <imageExpression><![CDATA["C:\Documents and Settings\I_blanco.bmp"]]></imageExpression> </image> </band> </title> <detail> <band height="353" splitType="Stretch"> <textField isStretchWithOverflow="true" isBlankWhenNull="false"> <reportElement uuid="2da276f9-b1f2-4029-9f3d-5e340c935ab8" isPrintRepeatedValues="false" x="0" y="0" width="555" height="86" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true"> <propertyExpression name="net.sf.jasperreports.export.pdf.tag.th"><![CDATA[$F{obs_Observa}]]></propertyExpression> <propertyExpression name="net.sf.jasperreports.export.pdf.tag.table"><![CDATA[$F{obs_Observa}]]></propertyExpression> <propertyExpression name="net.sf.jasperreports.export.pdf.tag.td"><![CDATA[$F{obs_Observa}]]></propertyExpression> <propertyExpression name="net.sf.jasperreports.export.pdf.tag.rowspan"><![CDATA[$F{obs_Observa}]]></propertyExpression> </reportElement> <textElement markup="html"> <font isBold="false" isStrikeThrough="false"/> </textElement> <textFieldExpression><![CDATA[$F{obs_Observa}]]></textFieldExpression> </textField> <componentElement> <reportElement uuid="2a982bc0-e4fe-4903-a6d6-d6479e8ba2db" positionType="Float" x="0" y="86" width="555" height="267" isPrintWhenDetailOverflows="true"/> <hc:html xmlns:hc="http://jasperreports.sourceforge.net/htmlcomponent" xsi:schemaLocation="http://jasperreports.sourceforge.net/htmlcomponent http://jasperreports.sourceforge.net/xsd/htmlcomponent.xsd" scaleType="Clip" horizontalAlign="Left" verticalAlign="Top"> <hc:htmlContentExpression><![CDATA["<table border=1' width='400px' height='auto'" + "style='font-family:helvetica; font-size:10pt !important; color:black;background-color:#FFFFFF;'>" + "<tr height='auto' style='width:100% !inportant; text-align:justify; '>" + "<td colspan='3'>"+$F{obs_Observa}+"</td>" + "</tr>"+ "</table>]]></hc:htmlContentExpression> </hc:html> </componentElement> </band> </detail> <pageFooter> <band height="56"/> </pageFooter></jasperReport>[/code]contributions 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