0

Currently my ireport generates report vertically and all of the data shows up properly. in example:

1 LM Test 1 LM
1T2e0st92 Elm
SStprreientgfield, TX
20192
{Hard Copy - Regular
Mail}

When i convert the report to horizontal report it cuts of the last line "{Hard Copy - Regular Mail}" Only prints out:

1 LM Test 1 LM
1T2e0st92 Elm
SStprreientgfield, TX
20192

Here is my xml code for horizontal report:

   <?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="Service Sheet Preview" columnCount="2" printOrder="Horizontal" pageWidth="612" pageHeight="792" columnWidth="286" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <style name="table">
        <box>
            <pen lineWidth="1.0" lineColor="#000000"/>
        </box>
    </style>
    <style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <subDataset name="Recipients">
        <field name="RECIPIENTS" class="java.lang.String"/>
    </subDataset>
    <parameter name="CSNL_ID" class="java.lang.String">
        <defaultValueExpression><![CDATA[]]></defaultValueExpression>
    </parameter>
    <parameter name="DOC_ID" class="java.lang.String">
        <defaultValueExpression><![CDATA[]]></defaultValueExpression>
    </parameter>
    <parameter name="PREVIEW" class="java.lang.String">
        <defaultValueExpression><![CDATA[]]></defaultValueExpression>
    </parameter>
    <queryString>
        <![CDATA[select
      distinct(csnl.id),
STUFF(
      (SELECT ', ' + clmt.C_LAST_NAME + ', ' + clmt.C_FIRST_NAME + ' V. ' + emplr.C_LAST_NAME + ', ' + emplr.C_FIRST_NAME
            from T_CSNL_RELATED_CASE d
            inner join T_CASE_INPUT c on d.C_CASE_ID = c.ID
            left join T_CONTACT clmt on cast(c.C_CLAIMANT_ID as int) = clmt.ID
            left join T_CONTACT emplr on cast (c.C_EMPLOYER_ID as int) = emplr.ID
            where d.ID_BASE = csnl.id
            FOR XML PATH(''))
            , 1,1,'')
as CASE_NAME,
     STUFF(
      (SELECT ', ' + C_CASE_NUMBER
            from T_CSNL_RELATED_CASE d
            where d.ID_BASE = csnl.id
            FOR XML PATH(''))
            , 1,1,'') AS CASE_NUMBER,
     (select c_title from t_document doc where id = $P{DOC_ID}) as TITLE,
     case when datepart(dd, getdate()) in(01, 21, 31) then convert(varchar, datepart(dd, getdate()))+'st'
          when datepart(dd, getdate()) in(02, 22) then convert(varchar, datepart(dd, getdate()))+'nd'
          when datepart(dd, getdate()) in(03, 23) then convert(varchar, datepart(dd, getdate()))+'rd'
          else convert(varchar, datepart(dd, getdate()))+'th'
     end as DAY,
     datename(mm, getdate()) as MONTH,
     datepart(yyyy, getdate()) as YEAR,
case when ct.c_title is null OR ct.c_title = '' then '' else ct.c_title+'<br>' end+
                                                       case when ct.c_organization is null OR ct.c_organization = '' then '' else ct.c_organization+'<br>' end+
                                ct.c_first_name+' '+ct.c_last_name +'<br>'+
                                                                                                                                dbo.OALJ_getContactAddress(ct.id, default) +'<br>'
                    +'<br>       {'+dt.c_name+'}'
                     as RECIPIENTS,
                                rcpts.C_ORDER as displayOrder
from t_csnl csnl
       join t_csnl_related_case csnlRC on csnl.id = csnlRC.id_base
      join (select id_base, c_contact, c_delivery_type, c_order from T_CSNL_ESR_RCPTS where id_base = $P{CSNL_ID}
               UNION select id_base, c_contact, c_delivery_type, c_order from T_CSNL_HARD_COPY_RCPTS where id_base = $P{CSNL_ID}
               UNION select id_base, c_contact, c_delivery_type, c_order from T_CSNL_STANDARD_RCPTS where id_base = $P{CSNL_ID}) rcpts on csnl.id = rcpts.id_base
      join t_contact ct on ct.id = rcpts.c_contact
     join t_csnl_delivery_type dt on dt.id = rcpts.c_delivery_type
      join t_case_input cs on csnlRC.c_case_id = cs.id
     join t_document doc on doc.id = $P{DOC_ID}
where csnl.id = $P{CSNL_ID} ORDER BY displayOrder ASC, 8 ASC]]>
    </queryString>
    <field name="id" class="java.math.BigDecimal"/>
    <field name="CASE_NAME" class="java.lang.String"/>
    <field name="CASE_NUMBER" class="java.lang.String"/>
    <field name="TITLE" class="java.lang.String"/>
    <field name="DAY" class="java.lang.String"/>
    <field name="MONTH" class="java.lang.String"/>
    <field name="YEAR" class="java.lang.Integer"/>
    <field name="RECIPIENTS" class="java.lang.String"/>
    <field name="displayOrder" class="java.lang.Integer"/>
    <variable name="RUNDATE" class="java.lang.String">
        <variableExpression><![CDATA[(new SimpleDateFormat("yyyy/MM/dd")).format(new Date())]]></variableExpression>
    </variable>
    <group name="ReportGroup1">
        <groupExpression><![CDATA[$F{CASE_NAME}]]></groupExpression>
        <groupHeader>
            <band height="148">
                <staticText>
                    <reportElement x="0" y="20" width="100" height="20"/>
                    <textElement>
                        <font fontName="Times New Roman"/>
                    </textElement>
                    <text><![CDATA[Case Number:]]></text>
                </staticText>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement x="100" y="20" width="472" height="20"/>
                    <textElement>
                        <font fontName="Times New Roman" isBold="true" pdfFontName="Times-Bold"/>
                    </textElement>
                    <textFieldExpression class="java.lang.String"><![CDATA[$F{CASE_NUMBER}]]></textFieldExpression>
                </textField>
                <staticText>
                    <reportElement x="0" y="40" width="100" height="20"/>
                    <textElement>
                        <font fontName="Times New Roman"/>
                    </textElement>
                    <text><![CDATA[Document Title:]]></text>
                </staticText>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement x="100" y="40" width="472" height="20"/>
                    <textElement>
                        <font fontName="Times New Roman" isBold="true" pdfFontName="Times-Bold" isPdfEmbedded="true"/>
                    </textElement>
                    <textFieldExpression class="java.lang.String"><![CDATA[$F{TITLE}]]></textFieldExpression>
                </textField>
                <staticText>
                    <reportElement x="0" y="0" width="100" height="20"/>
                    <textElement>
                        <font fontName="Times New Roman"/>
                    </textElement>
                    <text><![CDATA[Case Name:]]></text>
                </staticText>
                <textField>
                    <reportElement x="100" y="0" width="472" height="20"/>
                    <textElement>
                        <font fontName="Times New Roman" isBold="true" pdfFontName="Times-Bold"/>
                    </textElement>
                    <textFieldExpression class="java.lang.String"><![CDATA[$F{CASE_NAME}]]></textFieldExpression>
                </textField>
                <textField>
                    <reportElement x="0" y="60" width="572" height="28"/>
                    <textElement>
                        <font fontName="Times New Roman"/>
                    </textElement>
                    <textFieldExpression class="java.lang.String"><![CDATA["I hereby certify that a copy of the above-referenced document was sent to the following this "+$F{DAY}+" day of "+$F{MONTH}+", "+$F{YEAR}+":"]]></textFieldExpression>
                </textField>
                <textField>
                    <reportElement x="0" y="88" width="572" height="60"/>
                    <textElement>
                        <font fontName="Times New Roman" size="14" isBold="true" isItalic="true" isUnderline="false"/>
                    </textElement>
                    <textFieldExpression class="java.lang.String"><![CDATA[" "]]></textFieldExpression>
                </textField>
            </band>
        </groupHeader>
    </group>
    <background>
        <band height="752" splitType="Stretch">
            <printWhenExpression><![CDATA[$P{PREVIEW}.equals( "Yes" )]]></printWhenExpression>
            <staticText>
                <reportElement x="0" y="92" width="572" height="64" forecolor="#CCCCCC" backcolor="#FFFFFF"/>
                <textElement textAlignment="Center">
                    <font size="48" isBold="true"/>
                </textElement>
                <text><![CDATA[PREVIEW]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="220" width="572" height="64" forecolor="#CCCCCC"/>
                <textElement textAlignment="Center">
                    <font size="48" isBold="true"/>
                </textElement>
                <text><![CDATA[PREVIEW]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="348" width="572" height="64" forecolor="#CCCCCC"/>
                <textElement textAlignment="Center">
                    <font size="48" isBold="true"/>
                </textElement>
                <text><![CDATA[PREVIEW]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="476" width="572" height="64" forecolor="#CCCCCC"/>
                <textElement textAlignment="Center">
                    <font size="48" isBold="true"/>
                </textElement>
                <text><![CDATA[PREVIEW]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="604" width="572" height="64" forecolor="#CCCCCC"/>
                <textElement textAlignment="Center">
                    <font size="48" isBold="true"/>
                </textElement>
                <text><![CDATA[PREVIEW]]></text>
            </staticText>
        </band>
    </background>
    <title>
        <band height="34" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="0" width="572" height="27"/>
                <textElement textAlignment="Center">
                    <font fontName="Times New Roman" size="20" isBold="true" isUnderline="false"/>
                </textElement>
                <text><![CDATA[SERVICE SHEET]]></text>
            </staticText>
        </band>
    </title>
    <detail>
        <band height="42">
            <textField isStretchWithOverflow="true">
                <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="284" height="20" isPrintWhenDetailOverflows="true"/>
                <textElement markup="html">
                    <font fontName="Times New Roman" pdfFontName="Times-Roman" isPdfEmbedded="true"/>
                    <paragraph spacingAfter="20"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{RECIPIENTS}+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <summary>
        <band height="50">
            <printWhenExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()==0)]]></printWhenExpression>
            <staticText>
                <reportElement x="0" y="30" width="572" height="20"/>
                <textElement textAlignment="Center">
                    <font size="12"/>
                </textElement>
                <text><![CDATA[Your selection has returned no results]]></text>
            </staticText>
        </band>
    </summary>
</jasperReport>
Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
  • 1
    What is your question? Can you [edit] your question and provide some screenshots? – tobi6 Aug 16 '16 at 15:27
  • In which field do you have "{Hard Copy - Regular Mail}"? – Petter Friberg Aug 16 '16 at 15:48
  • It's on this line: +'
    {'+dt.c_name+'}'
    – Reazur Rahman Aug 16 '16 at 15:55
  • @PetterFriberg so i changed the report to `lineSpacing="Proportional" lineSpacingSize="1.0"` now it print out: 1 LM Test 1 LM 1T2e0st92 Elm SStprreientgfield, TX 20192 {Hard Copy - Regular Mail} – Reazur Rahman Aug 16 '16 at 16:17
  • @ReazurRahman are you exporting to pdf?, watch out you will need font-extensions – Petter Friberg Aug 16 '16 at 16:18
  • There is no spacing between the name and the address i had to change my sql to this for it work: `case when ct.c_title is null OR ct.c_first_name+' '+ct.c_last_name + dbo.OALJ_getContactAddress(ct.id, default) +' {'+dt.c_name+'}'. How can i have this work with the line break between the first and last name and also between contactAddress and dt.c_name ` – Reazur Rahman Aug 16 '16 at 16:19
  • @PetterFriberg Yes, I am exporting to PDF. How would i add the font extension – Reazur Rahman Aug 16 '16 at 16:20
  • From this answer you will find different links http://stackoverflow.com/questions/33940126/how-can-i-display-%C2%A3%E2%84%A6%E2%82%AC%CE%B1%CF%80%E2%85%94-in-jasperserver-pdf-using-ireport/33941102#33941102 – Petter Friberg Aug 16 '16 at 16:21
  • I would bet this is a font-extension problem, hence you have the problem when you export to pdf since it can't load the correct font (same as jasper report) and it starts to cut text. The easy way to use font-extension is to use the jasper-reports-fonts.jar (and use one of fonts included, dejavu) otherwise follow the links above – Petter Friberg Aug 16 '16 at 16:22
  • it is similar to this question: http://stackoverflow.com/questions/34271686/jasper-report-truncates-text-before-filling-the-whole-text-field/ – Petter Friberg Aug 16 '16 at 16:24
  • @PetterFriberg Too add the font i would need access to the core code that actually runs the java code to create the report right? In our job we don't have access to that . Is there anyway I can implement showing all of the values without adding the custom font. – Reazur Rahman Aug 16 '16 at 16:37
  • are you using jasper-sever or exporting in java code?, try to use default fonts not "Times new roman", if you are using jasper-server use the default jasper-reports fonts like "DejaVu Serif", anyway in both cases it's not that difficult to add font-extensions (create the jar and add it to classpath) – Petter Friberg Aug 16 '16 at 16:39
  • since you are using ireport this is a good guide http://community.jaspersoft.com/wiki/ireport-fonts , once you have the jar you only need to add it to classpath. – Petter Friberg Aug 16 '16 at 16:41
  • @PetterFriberg font was already set to times new roman just tried setting the font to Dejavu serif that didn't work either. – Reazur Rahman Aug 16 '16 at 16:42
  • The font name is "DejaVu Serif" and the jasper-reports-fonts.jar needs to be in classpath – Petter Friberg Aug 16 '16 at 16:43
  • @PetterFriberg i actually have all of the font installed and i tried the DejaVu Serif font it just changes the text font but still doesn't show up with all the info – Reazur Rahman Aug 16 '16 at 16:45
  • Meh, I still think you have a font problem, but I would need a [mcve] to test it, hence a small report with exactly the html string you are trying to render. – Petter Friberg Aug 16 '16 at 16:57
  • @PetterFriberg is just the ireport xml not good enough? The biggest problem seem to be the line break in this statement: ` ct.c_first_name+' '+ct.c_last_name +'
    '+ dbo.OALJ_getContactAddress(ct.id, default) +'
    ' +'
    {'+dt.c_name+'}' ` when i take those three line breaks out it works but the output looks weird because there is not line break between the name and the address
    – Reazur Rahman Aug 16 '16 at 17:12
  • [edit] your question to show exactly what html you are trying to render (hence the final output "1 LM Test 1 LM
    ...."), This way if I have time tonight I will test it with a similar text field as yours. We need an example that we can reproduce to understand your issue
    – Petter Friberg Aug 16 '16 at 17:14
  • @PetterFriberg Is this what you are asking for: `1 LM Test 1 LM Test
    12092 Elm Street
    Springfield, TX 20192

    {Hard Copy - Regular Mail} 2 LM Test 2 LM Test
    12093 Elm Street
    Springfield, UT 20193

    {Hard Copy - Regular Mail} CLMTRep Test
    2345 Maple Ave
    Fairfax, VA 20134

    {Hard Copy - Regular Mail} reazur rahman
    12067 Elm Street
    Springfield, LA 20167

    {Hard Copy - Regular Mail}`
    – Reazur Rahman Aug 16 '16 at 17:27
  • @PetterFriberg Changed the height of the filed and it worked like a charm. – Reazur Rahman Aug 16 '16 at 18:05

1 Answers1

0

So the main problem with this was the height of the field. I change the height of the field to 120 and it worked:

<detail>
        <band height="121">
            <textField isStretchWithOverflow="true">
                <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="284" height="120" isPrintWhenDetailOverflows="true"/>
                <textElement markup="html">
                    <font fontName="Times New Roman" pdfFontName="Times-Roman" isPdfEmbedded="true"/>
                    <paragraph spacingAfter="20"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{RECIPIENTS}+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"]]></textFieldExpression>
            </textField>
        </band>
    </detail>
  • hmm sure, but the field has isStretchWithOverflow="true", so it so should show all the content (hence stretch to required size) – Petter Friberg Aug 17 '16 at 21:37