2002 JI Open Discussion Posted August 18, 2006 Share Posted August 18, 2006 By: Adam Silverthorne - doog2112 Wrapping text 2003-06-18 14:26 Is there a way to force a line break in Jasper? I want to print an address at the top of my report, but I'm wondering if I can have a single text element in my design and then line break after each line, rather than having an element for the address, city, state etc... By: Gregory A. Swarthout - gswarthout RE: Wrapping text 2003-06-18 14:40 Concatenate them with good ole "n" By: Adam Silverthorne - doog2112 RE: Wrapping text 2003-06-18 14:57 Tried that but the n shows up in the report, no line break By: Gregory A. Swarthout - gswarthout RE: Wrapping text 2003-06-18 15:10 I use that technique in several of my reports. Can we see the code to yours? By: Adam Silverthorne - doog2112 RE: Wrapping text 2003-06-18 15:13 Sure. It supposed to be an invoice eventually. Hopefully this will come out okay in the webform. If I put the n in the STATIC text blocks (in the header) it just shows up as a n. Where are you putting it when it works properly? <?xml version="1.0"?> <!DOCTYPE jasperReport SYSTEM "file:////home/doog/development/propertyware/src/classes/report/dtd/jasperreport.dtd"> <jasperReport name="invoice" pageWidth="650" pageHeight="842" columnWidth="515" columnSpacing="0" leftMargin="40" rightMargin="40" topMargin="50" bottomMargin="50" whenNoDataType="AllSectionsNoDetail"> <reportFont name="Arial_Normal" isDefault="true" fontName="Arial" size="12" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> <reportFont name="Arial_Bold" isDefault="false" fontName="Arial" size="12" isBold="true" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> <reportFont name="Arial_Italic" isDefault="false" fontName="Arial" size="12" isItalic="true" pdfFontName="Helvetica-Oblique" pdfEncoding="Cp1252" isPdfEmbedded="false"/> <parameter name="invoiceID" class="java.lang.Long"/> <parameter name="pmTitle" class="java.lang.String"/> <parameter name="pmAddress1" class="java.lang.String"/> <parameter name="pmAddress2" class="java.lang.String"/> <parameter name="pmCity" class="java.lang.String"/> <parameter name="pmState" class="java.lang.String"/> <parameter name="pmZip" class="java.lang.String"/> <parameter name="invoiceNumber" class="java.lang.Integer"/> <parameter name="invoiceDate" class="java.util.Date"/> <parameter name="dueDate" class="java.util.Date"/> <parameter name="BaseDir" class="java.io.File"/> <queryString><![CDATA[select * from invoice_line_item where invoice_id = $P{invoiceID} order by item_id]]></queryString> <field name="quantity" class="java.lang.Integer"/> <field name="description" class="java.lang.String"/> <field name="unit_price" class="java.lang.Double"/> <title> <band height="300"> <textField isBlankWhenNull="true"> <reportElement x="0" y="10" width="325" height="40"/> <textElement textAlignment="Left" lineSpacing="Single"> <font reportFont="Arial_Bold" size="25"/> </textElement> <textFieldExpression class="java.lang.String">$P{pmTitle}</textFieldExpression> </textField> <staticText> <reportElement x="525" y="10" width="125" height="40"/> <textElement textAlignment="Left"> <font reportFont="Arial_Bold" size="25"/> </textElement> <text>INVOICE</text> </staticText> <textField isBlankWhenNull="true"> <reportElement x="0" y="50" width="325" height="15"/> <textElement textAlignment="Left" lineSpacing="Single"> <font reportFont="Arial_Normal" size="12"/> </textElement> <textFieldExpression class="java.lang.String">$P{pmAddress1}</textFieldExpression> </textField> <textField isBlankWhenNull="true"> <reportElement x="0" y="65" width="325" height="15"/> <textElement textAlignment="Left" lineSpacing="Single"> <font reportFont="Arial_Normal" size="12"/> </textElement> <textFieldExpression class="java.lang.String">$P{pmCity}</textFieldExpression> </textField> <textField isBlankWhenNull="true"> <reportElement x="0" y="80" width="325" height="15"/> <textElement textAlignment="Left" lineSpacing="Single"> <font reportFont="Arial_Normal" size="12"/> </textElement> <textFieldExpression class="java.lang.String">$P{pmState}</textFieldExpression> </textField> <textField isBlankWhenNull="true"> <reportElement x="0" y="95" width="325" height="15"/> <textElement textAlignment="Left" lineSpacing="Single"> <font reportFont="Arial_Normal" size="12"/> </textElement> <textFieldExpression class="java.lang.String">$P{pmZip}</textFieldExpression> </textField> <textField isBlankWhenNull="true"> <reportElement x="525" y="50" width="75" height="15"/> <textElement textAlignment="Left" lineSpacing="Single"> <font reportFont="Arial_Bold" size="12"/> </textElement> <textFieldExpression class="java.lang.String">"Invoice #" + $P{invoiceNumber}</textFieldExpression> </textField> <staticText> <reportElement x="525" y="65" width="50" height="15"/> <textElement textAlignment="Left"> <font reportFont="Arial_Bold" size="12"/> </textElement> <text>Date:</text> </staticText> <textField isBlankWhenNull="true" pattern="MM/dd/yyyy"> <reportElement x="575" y="65" width="75" height="15"/> <textElement textAlignment="Left" lineSpacing="Single"> <font reportFont="Arial_Bold" size="12"/> </textElement> <textFieldExpression class="java.util.Date">$P{invoiceDate}</textFieldExpression> </textField> <staticText> <reportElement x="525" y="80" width="50" height="15"/> <textElement textAlignment="Left"> <font reportFont="Arial_Bold" size="12"/> </textElement> <text>Due:</text> </staticText> <textField isBlankWhenNull="true" pattern="MM/dd/yyyy"> <reportElement x="575" y="80" width="75" height="15"/> <textElement textAlignment="Left" lineSpacing="Single"> <font reportFont="Arial_Bold" size="12"/> </textElement> <textFieldExpression class="java.util.Date">$P{dueDate}</textFieldExpression> </textField> <line> <reportElement x="0" y="119" width="650" height="1"/> <graphicElement pen="2Point"/> </line> <line direction="TopDown"> <reportElement x="0" y="120" width="1" height="130"/> <graphicElement pen="2Point"/> </line> <line direction="TopDown"> <reportElement x="325" y="120" width="1" height="130"/> <graphicElement pen="2Point"/> </line> <line direction="TopDown"> <reportElement x="650" y="120" width="1" height="130"/> <graphicElement pen="2Point"/> </line> <line> <reportElement x="0" y="250" width="650" height="1"/> <graphicElement pen="2Point"/> </line> <staticText> <reportElement x="10" y="125" width="50" height="15"/> <textElement textAlignment="Left"> <font reportFont="Arial_Bold" size="12"/> </textElement> <text>Bill To:</text> </staticText> </band> </title> <detail> <band height="20"> <textField> <reportElement x="0" y="4" width="200" height="15"/> <textFieldExpression class="java.lang.Integer"> $F{quantity} </textFieldExpression> </textField> <textField isStretchWithOverflow="true"> <reportElement x="200" y="4" width="110" height="15" positionType="Float"/> <textFieldExpression class="java.lang.String"> $F{description} </textFieldExpression> </textField> <textField isStretchWithOverflow="true"> <reportElement x="310" y="4" width="140" height="15" positionType="Float"/> <textFieldExpression class="java.lang.Double"> $F{unit_price} </textFieldExpression> </textField> </band> </detail> <pageFooter> <band height="40"> <textField> <reportElement x="270" y="20" width="80" height="15"/> <textElement textAlignment="Right"/> <textFieldExpression class="java.lang.String"> "Page " + String.valueOf($V{PAGE_NUMBER}) + " of " </textFieldExpression> </textField> <textField evaluationTime="Report"> <reportElement x="355" y="20" width="75" height="15"/> <textElement textAlignment="Left"/> <textFieldExpression class="java.lang.String"> " " + String.valueOf($V{PAGE_NUMBER}) </textFieldExpression> </textField> </band> </pageFooter> <summary> <band height="80"> <textField isStretchWithOverflow="true"> <reportElement x="250" y="20" width="165" height="15"/> <textElement textAlignment="Center"> <font reportFont="Arial_Italic"/> </textElement> <textFieldExpression class="java.lang.String"> " " + String.valueOf($V{REPORT_COUNT}) + " total" </textFieldExpression> </textField> </band> </summary> </jasperReport> By: Gregory A. Swarthout - gswarthout RE: Wrapping text 2003-06-18 15:22 In textFieldExpression it works like I described. Try replacing your staticTexts with textFields and see if that doesn't produce the results you desire. 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