Jump to content
We've recently updated our Privacy Statement, available here ×

Why do I lose textfield text over a page break using iReport?


bweaver2
Go to solution Solved by bweaver2,

Recommended Posts

 

I am using iReport 4.7.1.

I have a report which prints out a thread of email messages.

When I set the report to use 'Ignore Pagination' the report works properly (because there are no page breaks to mess up the data)

When I set the report to not 'Ignore Pagination' then over each page break I lose about 2 lines of text. 

 

To replicate: 1) Have text fields in the detail band of a report set to 'Stretch with overflow.' Print large amounts of text into these so that you trigger a page break. If your page break occurs in the middle of a paragraph you will lose date over the page break. 

 

For reference here is my XML:

 


<?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="MessageDetail" pageWidth="612" pageHeight="792" columnWidth="535" leftMargin="0" rightMargin="0" topMargin="20" bottomMargin="20" uuid="233a270a-37b6-42c2-8dc8-378f2d82445c">
<property name="ireport.scriptlethandling" value="2"/>
<property name="ireport.zoom" value="2.1398375295825036"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<import value="net.sf.jasperreports.engine.*"/>
<import value="java.util.*"/>
<import value="net.sf.jasperreports.engine.data.*"/>
<style name="Main" fontName="SansSerif" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
<parameter name="messageid" class="java.lang.Long" isForPrompting="false"/>
<parameter name="personid" class="java.lang.Long" isForPrompting="false"/>
<parameter name="hidden" class="java.lang.Boolean" isForPrompting="false"/>
<parameter name="reportfolder" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["C:/work/cleantelligent/src/report/"]]></defaultValueExpression>
</parameter>
<parameter name="languagetypeid" class="java.lang.String" isForPrompting="false"/>
<parameter name="subject" class="java.lang.String" isForPrompting="false"/>
<parameter name="reportImageFolder" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["C:/Work/cleantelligent/global/images/report/"]]></defaultValueExpression>
</parameter>
<parameter name="isSP" class="java.lang.Boolean" isForPrompting="false"/>
<parameter name="truncatelength" class="java.lang.Integer" isForPrompting="false">
<defaultValueExpression><![CDATA[integer.valueOf(-1)]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[sELECT replace(md.message, E't', ' ') as message,
md.messagedetailid,
md.hidden,
get_zonedate(md.date, get_user_timezone($P{personid})) as date,
p.firstname||' '||p.lastname as authorname
FROM messagedetail md, person p
WHERE md.messageid = $P{messageid}
AND md.authorid = p.personid
AND (NOT md.hidden OR $P{hidden})]]>
</queryString>
<field name="message" class="java.lang.String"/>
<field name="messagedetailid" class="java.lang.Long"/>
<field name="hidden" class="java.lang.Boolean"/>
<field name="date" class="java.lang.String"/>
<field name="authorname" class="java.lang.String"/>
<variable name="isOddRow" class="java.lang.Boolean">
<variableExpression><![CDATA[boolean.valueOf(!$V{isOddRow}.booleanValue())]]></variableExpression>
<initialValueExpression><![CDATA[boolean.FALSE]]></initialValueExpression>
</variable>
<variable name="isEvenRow" class="java.lang.Boolean">
<variableExpression><![CDATA[boolean.valueOf(!$V{isEvenRow}.booleanValue())]]></variableExpression>
<initialValueExpression><![CDATA[boolean.TRUE]]></initialValueExpression>
</variable>
<columnHeader>
<band height="16">
<printWhenExpression><![CDATA[boolean.valueOf($V{PAGE_NUMBER}.intValue() == 1)]]></printWhenExpression>
<image scaleImage="RetainShape" hAlign="Center" vAlign="Top" isUsingCache="false">
<reportElement uuid="862d1ded-438d-4081-8c4b-651f3d40c57c" key="image-2" x="0" y="2" width="12" height="12" forecolor="#000000" backcolor="#FFFFFF"/>
<box>
<topPen lineWidth="0.0" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineColor="#FFFFFF"/>
</box>
<graphicElement fill="Solid">
<pen lineWidth="0.0"/>
</graphicElement>
<imageExpression><![CDATA[$P{reportImageFolder} + "images/doc.gif"]]></imageExpression>
</image>
<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true">
<reportElement uuid="bdba68d1-2e3c-4d63-8c96-08c097c7fe54" key="textField-7" style="Main" mode="Opaque" x="14" y="0" width="537" height="15" forecolor="#FFFFFF" backcolor="#03368E"/>
<box>
<topPen lineWidth="0.0" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineColor="#220B8C"/>
<rightPen lineWidth="0.0" lineColor="#FFFFFF"/>
</box>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font fontName="Serif"/>
<paragraph lineSpacing="Single"/>
</textElement>
<textFieldExpression><![CDATA[msg($R{report.prompt.Subject.subject}, $P{subject})]]></textFieldExpression>
</textField>
</band>
</columnHeader>
<detail>
<band height="30">
<rectangle>
<reportElement uuid="131c7f5c-d88b-43cb-a827-efe6be36744c" stretchType="RelativeToBandHeight" x="14" y="0" width="537" height="6" isPrintWhenDetailOverflows="true" backcolor="#F0F0F0">
<printWhenExpression><![CDATA[$V{isOddRow}]]></printWhenExpression>
</reportElement>
<graphicElement>
<pen lineWidth="0.0"/>
</graphicElement>
</rectangle>
<rectangle>
<reportElement uuid="126be8f0-8f93-4d31-87c4-157ea847b9a5" stretchType="RelativeToBandHeight" x="14" y="0" width="537" height="6" isPrintWhenDetailOverflows="true" backcolor="#FAFAFA">
<printWhenExpression><![CDATA[$V{isEvenRow}]]></printWhenExpression>
</reportElement>
<graphicElement>
<pen lineWidth="0.0"/>
</graphicElement>
</rectangle>
<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true">
<reportElement uuid="497451a7-51b7-4277-b072-d656b476c0ed" key="textField-2" style="Main" mode="Transparent" x="17" y="0" width="362" height="13" forecolor="#000000" backcolor="#FFFFFF"/>
<box leftPadding="5">
<topPen lineWidth="0.0" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineColor="#FFFFFF"/>
</box>
<textElement textAlignment="Left" verticalAlignment="Top">
<font fontName="Serif"/>
<paragraph lineSpacing="Single"/>
</textElement>
<textFieldExpression><![CDATA[msg($R{report.prompt.Author.author}, $F{authorname})]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true">
<reportElement uuid="103e0af5-9016-4fc0-8291-4046d67445ca" key="textField-4" style="Main" mode="Transparent" x="379" y="0" width="172" height="13" forecolor="#000000"/>
<box leftPadding="5">
<topPen lineWidth="0.0" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineColor="#FFFFFF"/>
</box>
<textElement textAlignment="Left" verticalAlignment="Top">
<font fontName="Serif"/>
<paragraph lineSpacing="Single"/>
</textElement>
<textFieldExpression><![CDATA[msg($R{report.prompt.Date.date}, DateFormat.getDateInstance(DateFormat.LONG, $P{REPORT_LOCALE}).format(DateFormat.getDateInstance(DateFormat.SHORT).parse($F{date})) + $F{date}.substring(10))]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement uuid="36107c04-3729-44d5-a8a4-1ce38adfdd76" positionType="Float" mode="Transparent" x="29" y="14" width="522" height="1" forecolor="#FF0000" backcolor="#FFFFFF"/>
<textElement/>
<textFieldExpression><![CDATA[($F{hidden}.booleanValue() ? $R{report.prompt.HiddenNote.parenth.allCaps} : "")]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true">
<reportElement uuid="ab384095-4cb0-43af-89b4-148084f8639d" key="textField" positionType="Float" mode="Transparent" x="29" y="16" width="522" height="13" isPrintWhenDetailOverflows="true" forecolor="#000000" backcolor="#FFFFFF"/>
<box leftPadding="5">
<pen lineWidth="0.0"/>
<topPen lineWidth="0.0" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineColor="#FFFFFF"/>
</box>
<textElement textAlignment="Left" verticalAlignment="Top">
<font fontName="Serif"/>
<paragraph lineSpacing="Single"/>
</textElement>
<textFieldExpression><![CDATA[(($F{message}.length() > $P{truncatelength}.intValue() && $P{truncatelength}.intValue() != -1) ?
    $F{message}.substring(0, $P{truncatelength}.intValue()) + " " + $R{report.prompt.MessageTruncated} :
    $F{message})]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
 

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Solution

So I found this link after I posted this with the answer I needed. http://community.jaspersoft.com/questions/507861/losing-some-text-page-break

Here's the gist of what happened:

I was using a font that was not installed on my server. So, this caused the server to use a different font that what was specified the report. iReport calculates text usage on a per page basis before actually generating the report. So the font I wanted to use put 100 lines of text on a given page but the final version generated using the default font on my server could only fit 98 lines into the same space. This is what caused  the problem.

So to fix this I simply switched the font used in iReport to one of the fonts I knew I had installed on my server.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...