1

I have a very long static test. in my main jrxml (detail band), i created a sub-report to print this long static text. The output format is PDF. The long text is printed until the end of page, and then continue to next page. However, there some wording that had been left out / truncated in the next page.

ex. here is a very long long long static1 text long static2 text static3 static4

PDF output, page 1, it printed ("here is a very long long long static1"). But in page 2, it continue printed start with ("static3 static4"). few words are missing/truncated

This is the main jrxml. it has a frame defined. and inside this frame, will have subreport defined.

<frame>                   
<reportElement
    x="18"
    y="472"
    width="819"
    height="198"
    key="frame-4"
    positionType="Float"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
 
 
 
<subreport  isUsingCache="true">
    <reportElement
        mode="Transparent"
        x="3"
        y="31"
        width="350"
        height="12"
        key="subreport-21"
        positionType="Float"
        isRemoveLineWhenBlank="true"
        isPrintInFirstWholeBand="true"/>
    <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).dataSource("/PrintOrders/StructuredNote[NoteID='ST']")]]></dataSourceExpression>
    <subreportExpression  class="java.lang.String"><![CDATA["/print/FullPrint.jasper"]]></subreportExpression>
</subreport>
 
 
</frame>

this is the sub-report jrxml

<?xml version="1.0" encoding="UTF-8"  ?>
<!-- Created with iReport - A designer for JasperReports -->
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport
         name="FullPrint"
         columnCount="1"
         printOrder="Vertical"
         orientation="Landscape"
         pageWidth="842"
         pageHeight="595"
         columnWidth="842"
         columnSpacing="0"
         leftMargin="0"
         rightMargin="0"
         topMargin="0"
         bottomMargin="0"
         whenNoDataType="NoPages"
         scriptletClass="JasperUtil"
         isTitleNewPage="false"
         isSummaryNewPage="false"
         resourceBundle="AllBundles">
    <property name="ireport.scriptlethandling" value="2" />
    <property name="ireport.encoding" value="UTF-8" />
    <import value="java.util.*" />
    <import value="net.sf.jasperreports.engine.*" />
    <import value="net.sf.jasperreports.engine.data.*" />
 
 
    <parameter name="SUBREPORT_DIR" isForPrompting="true" class="java.lang.String">
        <defaultValueExpression ><![CDATA[".\\"]]></defaultValueExpression>
    </parameter>
    <queryString language="xPath"><![CDATA[PrintOrders/PrintOrder/PurchaseOrder]]></queryString>
 
    <field name="BLBST" class="java.lang.String">
        <fieldDescription><![CDATA[./GeneralNote]]></fieldDescription>
    </field>
    <field name="PoNumber" class="java.lang.String">
        <fieldDescription><![CDATA[./PoHeader/PoNumber]]></fieldDescription>
    </field>
 
    <sortField name="BLBScheduleId" />
 
 
        <group  name="PurchaseOrder" isReprintHeaderOnEachPage="true" >
            <groupExpression><![CDATA[$F{PoNumber}]]></groupExpression>
            <groupHeader>
            <band height="0"  isSplitAllowed="true" >
            </band>
            </groupHeader>
            <groupFooter>
            <band height="0"  isSplitAllowed="true" >
            </band>
            </groupFooter>
        </group>
        <background>
            <band height="0"  isSplitAllowed="true" >
            </band>
        </background>
        <title>
            <band height="0"  isSplitAllowed="true" >
            </band>
        </title>
        <pageHeader>
            <band height="0"  isSplitAllowed="true" >
            </band>
        </pageHeader>
        <columnHeader>
            <band height="0"  isSplitAllowed="true" >
            </band>
        </columnHeader>
        <detail>
            <band height="17"  isSplitAllowed="true" >
                <textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
                    <reportElement
                        x="3"
                        y="2"
                        width="821"
                        height="13"
                        key="textField-279"
                        positionType="Float"
                        isRemoveLineWhenBlank="true"/>
                    <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
                    <textElement>
                        <font pdfFontName="Helvetica" size="9" isBold="false"/>
                    </textElement>
                <textFieldExpression   class="java.lang.String"><![CDATA[$P{REPORT_SCRIPTLET}.doReplaceStringWithNewlineChar($F{BLBST})]]></textFieldExpression>
                </textField>
            </band>
        </detail>
        <columnFooter>
            <band height="0"  isSplitAllowed="true" >
            </band>
        </columnFooter>
        <pageFooter>
            <band height="0"  isSplitAllowed="true" >
            </band>
        </pageFooter>
        <summary>
            <band height="0"  isSplitAllowed="true" >
            </band>
        </summary>
</jasperReport>

here is what i have done and which already set.

  1. for the text box of the subreport, set "Stretch with Overfow" = true and "position type" = Float

  2. for the sub-report element in the main jrxml, i set "Position type" = Float and "Stretch Type"=no

I had try and error, lots of other config combination, for instance

  • Position Type = Float
  • Strech Type = Relative to tallest object or Relative to band height
  • Stretch with overflow = true

There other post in this forum, and i had tried most of them suggestion except for this below

  • setting font name same as pdf font name. because there is no value in both drop down selection list, that had same value in both drop down list

Here is the screen-cap. The top is the page 1, and there is a very long text which will then overflow to the next page. But, on the second page, the continuous sentence of text had been truncated.

enter image description here

Alex K
  • 22,315
  • 19
  • 108
  • 236
cjs
  • 341
  • 3
  • 7
  • [font-extensions](http://stackoverflow.com/documentation/jasper-reports/5773/font-extensions/20374/creating-and-using-font-extensions)? – Petter Friberg Sep 23 '16 at 19:36
  • @PetterFriberg, i am using the default font properties. net.sf.jasperreports.default.font.name=SansSerif - the default font name. net.sf.jasperreports.default.pdf.font.name=Helvetica - the default PDF font. net.sf.jasperreports.default.pdf.encoding=Cp1252 - the default PDF character encoding. – cjs Sep 24 '16 at 14:24
  • @PetterFriberg, is there a way i can print-out the font name/ font version during runtime, inside the pdf report layout? means during PDF generation – cjs Sep 24 '16 at 14:34
  • 1
    @cjs you should not use those attributes, you should font-extensions provide the .ttf to jasper reports and itext (pdf), this way you can be sure that metrics are calculated correctly and font rendered.These are just some of the post I answered with similar issue http://stackoverflow.com/questions/39304759/why-is-it-wrapping-text-in-jasper-report-6-3, http://stackoverflow.com/questions/39084407/why-is-text-truncated-in-pdf-with-linux/, 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 – Petter Friberg Sep 24 '16 at 16:08
  • @PetterFriberg. Many thanks to you. How can i placed a vote to your contribution ? – cjs Sep 26 '16 at 09:22
  • @cjs When you have some more reputation, you can upvote the answers you found useful. I'm happy they helped you out. – Petter Friberg Sep 26 '16 at 11:22
  • @PetterFriberg. upgrading jasper version from 3.5.3 to 4.5.0 is not advise-able to do so at my side. hence, i need to find another alternative. Having Font-Extension is do two things. One is to have custom design font to be used in PDF. second is to make sure those metrics font are calculated correctly. So, in my jrxml, i try to do the following ' ' . But it didnt work. Any thoughts ? – cjs Sep 27 '16 at 13:12
  • Why is it not advisable?, it's always advisable, I would upgrade 6... (note you can use old jtd-compiler if you have DDT problem in jrxml) – Petter Friberg Sep 27 '16 at 19:30
  • something to do with licensing, dependency impact on other report jrxml, and etc. @PetterFriberg, since i am not creating any custom font, it still make sense, if i just defined (fontName="SansSerif") so that it will consistently use SansSerif font, right ? but, it did not solve my issues in my case. maybe the default SansSerif (ttf file) that is bundled with JRE in linux is different from Windows ? – cjs Sep 28 '16 at 02:50
  • SansSerif in java is a logical font see http://stackoverflow.com/questions/39389324/is-there-a-common-font-format-for-jasper-on-linux-and-windows-to-produce-pdf/ (hence you can't be sure exactly to which physical font it is mapped), licensing, dependency impact?, can't really see the issue... – Petter Friberg Sep 28 '16 at 18:15

1 Answers1

1

@PetterFriberg suggestion had solve this issues. To help with others, just follow the links give by @PetterFriberg.

Additional info, i am using jasper version 3.5.3 And this version does not have this class. net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory

So, i upgrade my jar to jasperreports-4.5.0

cjs
  • 341
  • 3
  • 7
  • I have suggested a duplicate, consider to accept it (there is np having dupes, they actually serves as sign post, hence follow the link, other question same problem). I think you can leave this answer as it also states that you updated the jar. – Petter Friberg Sep 26 '16 at 11:25