fibrecrm Posted November 2, 2011 Share Posted November 2, 2011 I am trying to add a field to a report which prints six pages of formatted text (terms and conditions of sale). I tried adding a "Static Text" field but this does not expand the field vertically at compilation time. I have therefore added a "Text Field" to the Summary section of a report as this type of object can expand (Print When detail Overflows).I have set the "Markup" properties of the Text Field to RTF but am unsure where to paste the RTF content. I tried adding it to the "Edit Expression" and tried adding it to the "Print When Expression" with no luck on both counts. I've tried enclosing the RTF code in quotes " " but I just see errors.The RTF info is static text that does not exist in a database field (each report should contain the same text).Is what I'm trying to do possible? If it is, does anyone have any pearls of wisdom they can share with me about how to achieve this. Basically the report is an invoice which contains 6 pages of formatted terms and conditions.Many thanksSimon Link to comment Share on other sites More sharing options...
miqu Posted November 8, 2011 Share Posted November 8, 2011 I just put some html into a TextField as a parameter. So RTF should be the same just a different TextField Markup setting.You can load Parameters with Default Values. So I suppose If you have the RTF content as a File you can load the file as an inputstream and print it trough that TextField. The TextField:<textField isStretchWithOverflow="true" isBlankWhenNull="false"> <reportElement positionType="Float" x="0" y="54" width="227" height="15"/> <textElement markup="html"> <font fontName="Times New Roman" size="12"/> </textElement> <textFieldExpression><![CDATA[$P{paramNameForYourContent}]]></textFieldExpression></textField> And setting that Parameter using a oneliner from StackOverFlow to convert inputstream to string:<parameter name="paramNameForYourContent" class="java.lang.String" isForPrompting="false"> <defaultValueExpression><![CDATA[(new java.util.Scanner(new java.io.FileInputStream(new java.io.File("C:\SomePlace\pathandFilenametoYour.html")))).useDelimiter("\A").next()]]></defaultValueExpression></parameter>You should just need to change the markup to RTF and load your RTF document. I tested this to work with some html in a file.Post Edited by miqu at 11/08/2011 16:30 Link to comment Share on other sites More sharing options...
fibrecrm Posted November 8, 2011 Author Share Posted November 8, 2011 Thanks for your response and help with this. Much appreciated.I am seeing errors when compiling the report. The report is set to Groovy but I have also tried Java. When set to Java I see the error "Invalid Unicode". When set to Groovy the error is "....Startup Failed. General Error during parsing: Did not find four digit hex character code...."I have created a parameter <parameter name="parameter1" class="java.lang.String" isForPrompting="false"> <parameterDescription><![CDATA[]]></parameterDescription> <defaultValueExpression><![CDATA[(new java.util.Scanner(new java.io.FileInputStream(new java.io.File("C:\users\SouthwestCRM\test.html")))).useDelimiter("\A").next()]]></defaultValueExpression> </parameter>I have created a TextField<textField isStretchWithOverflow="true" isBlankWhenNull="false"> <reportElement x="18" y="12" width="518" height="20" isPrintWhenDetailOverflows="true"/> <textElement markup="html"/> <textFieldExpression><![CDATA[$P{parameter1}]]></textFieldExpression>Ultimately I would like the HTML/RTF to be embedded in the report rather than linked to a file on my PC or if this is not possible then to place on a website somewhere since the report will eventually run within a JasperServer web app.I'm not sure where to look to resolve this. Link to comment Share on other sites More sharing options...
perkas Posted November 17, 2011 Share Posted November 17, 2011 Hi, I have the same problem.. /tools/fckeditor/editor/images/smiley/msn/cry_smile.gifDo you know in witch iReport version included the "markup=html" property on textElement? (I am using iReports 2.0.2, and i can´t see that property...)I am using jdk 1.4.2_12 version. Dou you know waht is the maximun iReport version that support java 1.4?Thank you and best regards! /tools/fckeditor/editor/images/smiley/msn/wink_smile.gif Link to comment Share on other sites More sharing options...
svenn Posted November 17, 2011 Share Posted November 17, 2011 perkas,I beleive the last version to support Java 1.4 is Jasper 3.0. It also supports html markup. Link to comment Share on other sites More sharing options...
perkas Posted November 18, 2011 Share Posted November 18, 2011 Thanks!, although very few html tags works properly:If i put text "Hello <U>my</U> friend." it render "Hello friend".."<b>" neither works, and "<p>" render as "<br><br>".Do you know how to solve this?I mark stick in "Styled text" property and "Markup=html"Thanks you!! Link to comment Share on other sites More sharing options...
perkas Posted November 18, 2011 Share Posted November 18, 2011 I solve myself enclosing text in Xml node with "<![CDATA["The only HTML tags avalaible are: <b> <u> <i> <font> <sup> <sub> <li> <br> Here is the list:jasperforge.org/uploads/publish/jasperreportswebsite/trunk/sample.reference/styledtext/index.htmlAnd here a explain of how to use "Styled Text":jasperreports.sourceforge.net/sample.reference/markup/index.html Post Edited by perkas at 11/22/2011 08:32 Link to comment Share on other sites More sharing options...
fibrecrm Posted November 20, 2011 Author Share Posted November 20, 2011 Ok, so I have it working when referencing a file on my local pc. Now I have uploaded the report to Jasperserver I would like to point to a web location for the RTF file. How best to do this? Can I upload the RTF file as a resource to the report? If I place it on a website somewhere, then how to reference it within the report?Currently it works like:<defaultValueExpression><![CDATA[(new java.util.Scanner(new java.io.FileInputStream(new java.io.File("C:\\Users\\contract.rtf")))).useDelimiter("\\A").next()]]></defaultValueExpression>I would like something like:<defaultValueExpression><![CDATA[(new java.util.Scanner(new java.io.FileInputStream(new java.io.File("http://www.somewhere.com/contract.rtf")))).useDelimiter("\\A").next()]]></defaultValueExpression>Is the issue an escape sequence or do I need to use a different java.io function to reference a file on the web?Thanks! Link to comment Share on other sites More sharing options...
fibrecrm Posted November 24, 2011 Author Share Posted November 24, 2011 So, does anyone know why the following might not workjava.io.File("http://www.somewhere.com/contract.rtf") Link to comment Share on other sites More sharing options...
Semicolon Posted April 15, 2014 Share Posted April 15, 2014 java.io.File only works with files on the disk, to use http to get a file you can do something like this: new java.util.Scanner(new URL("http://somewhere.com/contract.rtf").openStream()).useDelimiter("\A").next() Link to comment Share on other sites More sharing options...
pratapkumar.martha Posted October 30, 2015 Share Posted October 30, 2015 Hi All,I use below process<textField isStretchWithOverflow="true" isBlankWhenNull="false"> <reportElement x="18" y="12" width="518" height="20" isPrintWhenDetailOverflows="true"/> <textElement markup="rtf"/> <textFieldExpression><![CDATA[$P{parameter1}]]></textFieldExpression>But I got only text, How I can export graphics content (Image, Table) with text ?Thanks, 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