Hi all,
i have a long text (general sales conditions) and i'm trying to figure out how to split it into 2 column with the same height.
The text isn't static, so it can change whenever it need to be changed (e.g. customer specific text) and for this reason i can't split it manually.
Using 2 columns page format i managed to let Jasper fill one column at a time, but my customer doesn't want 2 column with different heights.
Can someone help me?
P.S. I'm using Jaspersoft Studio 6.0.3.
Thank you in advance,
Giuliano
4 Answers:
Posted on April 15, 2015 at 2:16pm
Try this report:using a postgreSQL data source
<?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="report4Giuliano" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="1fe3275c-4ced-4197-979c-9f5ffd79bb93"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="JRSrepo"/> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <parameter name="Parameter1" class="java.lang.String"> <defaultValueExpression><![CDATA["10 Things Not To Do On Tax Day - 1. Fib on your taxes and think you’ll pay later. - 2. Call your tax professional for anything other than an extension. - 3. Spend your refund when it’s not in pocket. - 4. Head out for the post office at 4:55pm. - 5. Call the IRS. - 6. Forget to sign your return. - 7. Assume you’ll figure it out later. - 8. Not pay at all. - 9. Fail to take advantage of all of the cool stuff available. - 10. Panic. (http://www.forbes.com/sites/kellyphillipserb/2015/04/15/9-things-not-to-do-on-tax-day/)"]]></defaultValueExpression> </parameter> <queryString> <![CDATA[select 1]]> </queryString> <field name="?column?" class="java.lang.Integer"/> <variable name="split_point" class="java.lang.Integer"> <variableExpression><![CDATA[new Integer(($P{Parameter1}.length()/2)+$P{Parameter1}.substring($P{Parameter1}.length()/2).indexOf(" "))]]></variableExpression> </variable> <variable name="split_point2" class="java.lang.Integer"> <variableExpression><![CDATA[new Integer($P{Parameter1}.substring(0,$P{Parameter1}.length()/2).lastIndexOf(" "))]]></variableExpression> </variable> <background> <band splitType="Stretch"/> </background> <title> <band height="1" splitType="Stretch"/> </title> <pageHeader> <band splitType="Stretch"/> </pageHeader> <columnHeader> <band splitType="Stretch"> <property name="local_mesure_unitheight" value="pixel"/> <property name="com.jaspersoft.studio.unit.height" value="px"/> </band> </columnHeader> <detail> <band height="45" splitType="Stretch"> <property name="local_mesure_unitheight" value="pixel"/> <property name="com.jaspersoft.studio.unit.height" value="px"/> <textField isStretchWithOverflow="true"> <reportElement stretchType="RelativeToTallestObject" mode="Opaque" x="0" y="0" width="285" height="30" backcolor="#F7C8F0" uuid="876f86fd-6283-4c6e-bd4e-556363a92476"> <property name="local_mesure_unitwidth" value="pixel"/> <property name="com.jaspersoft.studio.unit.width" value="px"/> </reportElement> <textFieldExpression><![CDATA[$P{Parameter1}]]></textFieldExpression> </textField> </band> <band height="50"> <textField isStretchWithOverflow="true"> <reportElement stretchType="RelativeToTallestObject" mode="Opaque" x="0" y="0" width="285" height="30" backcolor="#93F595" uuid="ef3e1934-fb73-46aa-81ea-b9875009f7c6"> <property name="local_mesure_unitwidth" value="pixel"/> <property name="com.jaspersoft.studio.unit.width" value="px"/> </reportElement> <textFieldExpression><![CDATA[$P{Parameter1}.substring(0,$V{split_point}.intValue())]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true"> <reportElement stretchType="RelativeToTallestObject" mode="Opaque" x="287" y="0" width="285" height="30" backcolor="#E6F593" uuid="08c692a3-adab-4511-9c2b-ddf4ba98c400"> <property name="local_mesure_unitx" value="pixel"/> <property name="com.jaspersoft.studio.unit.x" value="px"/> </reportElement> <textFieldExpression><![CDATA[$P{Parameter1}.substring($V{split_point}.intValue()+1)]]></textFieldExpression> </textField> </band> </detail> <columnFooter> <band splitType="Stretch"/> </columnFooter> <pageFooter> <band splitType="Stretch"/> </pageFooter> <summary> <band splitType="Stretch"/> </summary> </jasperReport>
Posted on April 16, 2015 at 12:47am
Thank you, but one of the problems is that the text is very, very long... like this: http://www.ensto.com/ensto/workingprinciples/generalconditions
So the entire text falls into many pages and this isn't enough.
However you gave me an idea... if i manage to get the maximum characters that goes into a single page i can create different reports each with different parts of the text using your template...
Posted on April 16, 2015 at 11:51am