jasper reports textfeild word break problem - jasper-reports

enter image description here
When outputting a report in pdf
Line breaks occur when Japanese characters meet long strings of English or numbers.
enter image description here
I want to fix it as this
my jasper reports version is 6.19.0
i changed textfeild's property setting but are not related to line breaks
<textField isBlankWhenNull="true">
<reportElement x="62" y="553" width="453" height="65" uuid="4515728e-b1ba-4e04-8408-966351f73670">
<property name="net.sf.jasperreports.export.pdf.field.type" value="Text"/>
<property name="net.sf.jasperreports.export.pdf.field.text.multiline" value="true"/>
<property name="net.sf.jasperreports.export.pdf.field.choice.separators" value=""/>
<property name="net.sf.jasperreports.allow.element.overlap" value="false"/>
</reportElement>
<textElement textAlignment="Left" verticalAlignment="Top">
<font fontName="IPAex" size="11"/>
<paragraph lineSpacingSize="0.0"/>
</textElement>
<textFieldExpression><![CDATA[$F{data}]]></textFieldExpression>
</textField>

Related

how to make the cell stretch as per the length of the data in the cell (<textField isStretchWithOverflow="true">) [duplicate]

This question already has answers here:
How to stretch textfield in a JasperReport as per dynamic content?
(8 answers)
Stretch overflow not working in excel jasper report
(3 answers)
Can JasperReports produce Excel file with column widths auto adjusted to contents?
(1 answer)
iReport issue with isStretchWithOverflow
(1 answer)
JasperReport - wrap text to show long text in textfield
(3 answers)
Closed 3 months ago.
enter image description hereenter image description herefor the report, i want the cell to stretch as per the length of the data in the cell
currently my report looks like this
the code:
<jr:column width="100" uuid="a1e76d15-849b-4f0c-a863-05a154d5291c">
<jr:detailCell style="Table_TD" height="15">
<textField isStretchWithOverflow="true">
<reportElement x="0" y="0" width="100" height="15" uuid="c86863d7-007b-4a35-b616-01c4aec548dd">
<property name="net.sf.jasperreports.export.xls.auto.fit.row" value="true"/>
<property name="net.sf.jasperreports.export.xls.auto.fit.column" value="true"/>
<property name="net.sf.jasperreports.export.xls.wrap.text" value="false"/>
<property name="net.sf.jasperreports.print.keep.full.text" value="true"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="DejaVu Sans" size="10" isBold="false" pdfFontName="DejaVu Sans" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{uom} != null ? $F{uom} : "-"]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
as you can see the uom, the data inside the cell is croped and sticks close to the cell
expected :
cell to stretch as per the length of the data
or
want the data inside the cell to not get cropped
or
any better way to give proper alignment
Note : i tried width= "150" , still the same result
Add:
<paragraph leftIndent="5" rightIndent="5"/> below <font... >
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="DejaVu Sans" size="10" isBold="false" pdfFontName="DejaVu Sans" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
<paragraph leftIndent="5" rightIndent="5"/>
</textElement>
Adding < paragraph leftIndent="5" rightIndent="5"/ > will create indent of 5 on both sides
**For Top and Bottom margin **
Increase cell height:
<jr:column width="100" uuid="a1e76d15-849b-4f0c-a863-05a154d5291c">
<jr:detailCell style="Table_TD" height="15"> as you have already set vertical alignment middle, extra height will be distributed on top and bottom for example you can try setting
<jr:detailCell style="Table_TD" height="25">

How do I prevent text overflowing into the next cell in a Jasper Report that exports to Excel?

I am creating a jrxml in Jaspersoft Studio that exports a table to Excel. When I view the Excel output, the data in the last column is overflowing into the next cell like so:
I am trying to prevent the data from overflowing into the next cell without wrapping the data in the cell.
I was able to find a reference for why Excel does overflow text: https://www.ablebits.com/office-addins-blog/stop-text-spilling-over-excel/
One of the solutions is to manually Format Cells and change horizontal text alignment to 'Fill'. This gives me the following table, which is exactly what I need:
However, I was not able to find a way to configure my jrxml to obtain this behavior. How may I create my jrxml such that it will export to Excel without overflowing text into adjacent columns (without wrapping the text)?
I don't think text alignment 'Fill' can be set when exporting to XLS.
One (kinda dirty) solution is having a 'blank' cell next to COL2 which will prevent the text in COL2 overflowing into the 'blank' cell.
Your example (modified):
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.20.0.final using JasperReports Library version 6.1.1 -->
<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="Blank_A4" pageWidth="240" pageHeight="400" columnWidth="200" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="af068097-e37b-4e41-9083-4c7b8e13c800">
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<property name="net.sf.jasperreports.export.xls.wrap.text" value="false"/>
<property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<subDataset name="Dataset1" uuid="f12cc232-2035-43e1-b3e3-a446ee7318bf">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<queryString>
<![CDATA[select 'abcdefghijklmnopqrstuvwxyz' as data1,
'abcdefghijklmnopqrstuvwxyz' as data2]]>
</queryString>
<field name="data1" class="java.lang.String"/>
<field name="data2" class="java.lang.String"/>
</subDataset>
<queryString>
<![CDATA[select 1]]>
</queryString>
<detail>
<band height="359" splitType="Stretch">
<componentElement>
<reportElement x="0" y="0" width="220" height="60" uuid="6a7376a7-6ee6-4e94-8e7b-024170505320">
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<c:table xmlns:c="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="Dataset1" uuid="0fee875c-6568-4a06-a8e4-f7fb34ebd4e5"/>
<c:column width="100" uuid="6517d845-8cbe-44b6-a644-cedfc40576c9">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/>
<c:columnHeader height="30" rowSpan="1">
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="100" height="30" forecolor="#FFFFFF" backcolor="#7845D9" uuid="f222fdba-a6db-46dd-97a5-e8e0181aa7e4">
<propertyExpression name="net.sf.jasperreports.export.xls.wrap.text"><![CDATA["true"]]></propertyExpression>
</reportElement>
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="1.5"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[COL1]]></text>
</staticText>
</c:columnHeader>
<c:detailCell height="30">
<textField isBlankWhenNull="true">
<reportElement mode="Opaque" x="0" y="0" width="100" height="30" uuid="2a235121-a4f3-487b-8138-edc5b5340e50"/>
<box>
<pen lineWidth="0.5"/>
</box>
<textElement verticalAlignment="Middle">
<paragraph leftIndent="3"/>
</textElement>
<textFieldExpression><![CDATA[$F{data1}]]></textFieldExpression>
</textField>
</c:detailCell>
</c:column>
<c:column width="100" uuid="23415ab5-ef42-4f13-9395-cc9bb019149a">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/>
<c:columnHeader height="30" rowSpan="1">
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="100" height="30" forecolor="#FFFFFF" backcolor="#7845D9" uuid="8ecbe731-1442-40b4-94a6-f3c57337704c">
<propertyExpression name="net.sf.jasperreports.export.xls.wrap.text"><![CDATA["true"]]></propertyExpression>
</reportElement>
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="1.5"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[COL2]]></text>
</staticText>
</c:columnHeader>
<c:detailCell height="30">
<textField isBlankWhenNull="true">
<reportElement mode="Opaque" x="0" y="0" width="100" height="30" uuid="c8f16b37-4f63-4043-abc6-d321125c247e"/>
<box>
<pen lineWidth="0.5"/>
</box>
<textElement verticalAlignment="Middle">
<paragraph leftIndent="3"/>
</textElement>
<textFieldExpression><![CDATA[$F{data2}]]></textFieldExpression>
</textField>
</c:detailCell>
</c:column>
<c:column width="20" uuid="4fff907e-9cb8-41d3-a264-b78ca5ed814a">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column3"/>
<c:columnHeader height="30" rowSpan="1"/>
<c:detailCell height="30">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<textField>
<reportElement x="0" y="0" width="20" height="30" uuid="eb0dd902-0635-4a55-8f84-03834107f2bf"/>
<textFieldExpression><![CDATA[""]]></textFieldExpression>
</textField>
</c:detailCell>
</c:column>
</c:table>
</componentElement>
</band>
</detail>
</jasperReport>

JasperReport image dynamic vertical stretching depending on page size - can it be done?

I have a jasper report that looks like a certificate.
I have a background image that serves as the attractive bordering or frame of the whole page.
The problem is, if for example, the name in text field is much bigger than the element container, it creates extra white space in the bottom.
The background image / frame is not stretching to stretch the the whole edges of the page.
The same is true when the text fields are shorter. But in this case, the page is shortened to the point that you almost cannot see the bottom portion of the frame.
I want the image to dynamically stretch depending on the final size of the page at runtime.
Here is the look of my design:
This is what happens when it is compiled, as you can see there are extra white spaces at the bottom:
This is the current setting of my image..
Position Type: Float
Stretch Type: ContainerBottom
The jrxml
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b -->
<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="paiwi-certificate-pdf" pageWidth="792" pageHeight="612" orientation="Landscape" columnWidth="792" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" isIgnorePagination="true" uuid="28bcb6f8-04d6-48df-ab31-e1bedc2f2434">
<property name="net.sf.jasperreports.print.create.bookmarks" value="false"/>
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String"/>
<parameter name="farmContactListSubreportDataSource" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
<parameter name="farmName" class="java.lang.String"/>
<parameter name="farmLogo" class="java.lang.String"/>
<parameter name="farmAddress" class="java.lang.String"/>
<parameter name="farmBusinessAddress" class="java.lang.String"/>
<parameter name="temporaryPartnersName" class="java.lang.String"/>
<parameter name="partnerName" class="java.lang.String"/>
<parameter name="partnerContactNumber" class="java.lang.String"/>
<parameter name="partnerEmail" class="java.lang.String"/>
<parameter name="packageName" class="java.lang.String"/>
<parameter name="batchName" class="java.lang.String"/>
<queryString>
<![CDATA[]]>
</queryString>
<detail>
<band height="612" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<staticText>
<reportElement positionType="Float" x="146" y="80" width="224" height="40" forecolor="#332411" uuid="cb95bd0b-631e-4363-80f5-22d0b0e481fe">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement markup="none">
<font fontName="Georgia" size="34" isBold="false"/>
</textElement>
<text><![CDATA[CERTIFICATE]]></text>
</staticText>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement positionType="Float" x="50" y="372" width="446" height="28" uuid="6281f2a7-4eca-4319-b298-22184617a6d3">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font fontName="Georgia" size="24" isBold="false" isUnderline="false"/>
</textElement>
<textFieldExpression><![CDATA[$P{farmName}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement positionType="Float" x="50" y="400" width="446" height="17" uuid="f19dc14b-3ada-460b-8633-85fd5a896d45">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font fontName="Georgia" size="14" isBold="false" isUnderline="false"/>
</textElement>
<textFieldExpression><![CDATA[$P{farmAddress}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement positionType="Float" x="50" y="417" width="446" height="17" uuid="dec9944a-2758-4202-acfe-6f97df346b8f">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font fontName="Georgia" size="14" isBold="false" isUnderline="false"/>
</textElement>
<textFieldExpression><![CDATA[$P{farmBusinessAddress}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement positionType="Float" x="164" y="180" width="473" height="40" forecolor="#332411" uuid="b2a59bb8-1557-498f-b17a-3f0e561bb11b">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textElement textAlignment="Center">
<font fontName="Georgia" size="37" isBold="false" isUnderline="false"/>
</textElement>
<textFieldExpression><![CDATA[$P{partnerName} != null && !$P{partnerName}.equalsIgnoreCase("") ? $P{partnerName} : $P{temporaryPartnersName}]]></textFieldExpression>
</textField>
<image onErrorType="Blank">
<reportElement positionType="Float" x="569" y="338" width="164" height="160" uuid="717d6475-3d42-4e54-a69a-7271bc862e33"/>
<imageExpression><![CDATA[$P{farmLogo}]]></imageExpression>
</image>
<staticText>
<reportElement positionType="Float" x="416" y="81" width="228" height="40" forecolor="#332411" uuid="f2a78f2d-ed74-45b9-89e8-3365c4afe801">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement markup="none">
<font fontName="Georgia" size="34" isBold="false"/>
</textElement>
<text><![CDATA[COMPLETION]]></text>
</staticText>
<staticText>
<reportElement positionType="Float" x="378" y="80" width="33" height="40" forecolor="#332411" uuid="e1c7ac87-81ce-4e8d-b718-2aee4f139003"/>
<textElement markup="none">
<font fontName="Georgia" size="34" isBold="false" isItalic="true"/>
</textElement>
<text><![CDATA[of]]></text>
</staticText>
<staticText>
<reportElement positionType="Float" x="311" y="148" width="179" height="15" forecolor="#6E6E6E" uuid="3d5afae8-14e2-4a3b-8471-db8388e2309f">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement markup="none">
<font fontName="Verdana" size="12" isBold="false"/>
<paragraph lineSpacingSize="1.0"/>
</textElement>
<text><![CDATA[THIS ACKNOWLEDGES THAT]]></text>
</staticText>
<staticText>
<reportElement positionType="Float" x="290" y="249" width="232" height="15" forecolor="#6E6E6E" uuid="4c301efe-c460-478e-873a-d16430000b18">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement markup="none">
<font fontName="Verdana" size="12" isBold="false"/>
<paragraph lineSpacingSize="1.0"/>
</textElement>
<text><![CDATA[HAS SUCCESSFULLY COMPLETED THE]]></text>
</staticText>
<staticText>
<reportElement positionType="Float" x="50" y="357" width="232" height="15" forecolor="#6E6E6E" uuid="1060f753-1051-4925-9efe-c2ee62146b25">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement markup="none">
<font fontName="Verdana" size="12" isBold="false"/>
<paragraph lineSpacingSize="1.0"/>
</textElement>
<text><![CDATA[ACKNOWLEDGED BY:]]></text>
</staticText>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement positionType="Float" x="275" y="279" width="263" height="17" uuid="3ab3ec94-b64f-42df-b475-7996bcac1abb">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Center">
<font fontName="Georgia" size="14" isBold="false" isUnderline="false"/>
</textElement>
<textFieldExpression><![CDATA[$P{packageName}]]></textFieldExpression>
</textField>
<staticText>
<reportElement positionType="Float" x="359" y="296" width="43" height="16" forecolor="#000000" uuid="c6e10785-2750-4247-af0c-6cbafa3aa294"/>
<textElement markup="none">
<font fontName="Georgia" size="14" isBold="false"/>
<paragraph lineSpacingSize="1.0"/>
</textElement>
<text><![CDATA[Batch:]]></text>
</staticText>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement positionType="Float" x="402" y="296" width="48" height="16" forecolor="#000000" uuid="dff76163-3fd3-4bf6-94fd-de4612485e29">
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textElement textAlignment="Center">
<font fontName="Georgia" size="14" isBold="false" isUnderline="false"/>
</textElement>
<textFieldExpression><![CDATA[$P{batchName}]]></textFieldExpression>
</textField>
<image onErrorType="Blank">
<reportElement positionType="Float" x="140" y="279" width="126" height="30" uuid="b0c2acd4-1a0c-4fe6-9a94-be43fe67d704"/>
<imageExpression><![CDATA["https://i.imgur.com/Ug4T4oX.png"]]></imageExpression>
</image>
<image onErrorType="Blank">
<reportElement positionType="Float" x="550" y="279" width="126" height="30" uuid="9d2cddda-e519-42e2-b74b-554f4c102ef2"/>
<imageExpression><![CDATA["https://i.imgur.com/paQHNxJ.png"]]></imageExpression>
</image>
<image scaleImage="RetainShape" vAlign="Bottom" onErrorType="Blank" evaluationTime="Page">
<reportElement positionType="Float" stretchType="ContainerBottom" x="0" y="0" width="782" height="612" isPrintInFirstWholeBand="true" uuid="2dadd1da-0694-4e21-86de-fae790844411">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<imageExpression><![CDATA["https://i.imgur.com/y8uffu8.png"]]></imageExpression>
</image>
</band>
</detail>
</jasperReport>
I think your only problem is that you do not have the correct scaleImage property set, hence the element is actually resizing but since you have scaleImage="RetainShape" the image will not fill the new element dimension but instead maintain orignal image proportions
From Jasper Reports Ultimate guide:
Clipping the image: If the actual image is larger than the image element size, it will be cut off so that it keeps its original
resolution, and only the region that fits the specified size will be
displayed (scaleImage="Clip").
Forcing the image size: If the dimensions of the actual image do not fit those specified for the image element that displays it, the image
is forced to obey them and stretch itself so that it fits in the
designated output area. It will be deformed if necessary
(scaleImage="FillFrame").
Keeping the image proportions: If the actual image does not fit into the image element, it can be adapted to those dimensions while
keeping its original undeformed proportions
(scaleImage="RetainShape").
Stretching the image keeping the width: The image can be stretched vertically to match the actual image height, while preserving the
declared width of the image element (scaleImage="RealHeight").
Stretching the image adjusting the width: The image can be stretched vertically to match the actual image height, while adjusting
the width of the image element to match the actual image width
(scaleImage="RealSize").
So you need:
scaleImage="FillFrame"
something like this
<image scaleImage="FillFrame" vAlign="Bottom" onErrorType="Blank">
<reportElement stretchType="ContainerHeight" x="10" y="0" width="782" height="612" uuid="2dadd1da-0694-4e21-86de-fae790844411">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<imageExpression><![CDATA["https://i.imgur.com/y8uffu8.png"]]></imageExpression>
</image>

jasper excel report export green mark coming

I am using jasper stuido 6 to generated excel report.
After generating report I am getting green mark on cell wherever is number is coming as shown below image
same green mark is not coming from text value only.
I tried to set the below jasper property
<property name="net.sf.jasperreports.export.xls.detect.cell.type" value="true"/>
and used below code
<jr:column width="50" uuid="d3d82c7c-1121-474f-b0f3-00e80cda4489">
<jr:detailCell height="20">
<textField>
<reportElement style="WhiteBackColor" x="0" y="0" width="50" height="20" uuid="1b71e76d-8111-43ee-9cfb-9070ffcf1f6d">
<printWhenExpression><![CDATA[$F{zeitQuartal}.matches("-?\\d+(\\.\\d+)?")]]></printWhenExpression>
</reportElement>
<textElement verticalAlignment="Middle">
<font fontName="Calibri" size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[Double.parseDouble($F{zeitQuartal})]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
Then green mark disapper from the generated excel report
but if any text like come in between number that is disappearing

Subreport with negative y coordinate prints wrong on second page with jaspersoft

I'm currently working with Jaspersoft Studio (version 5.6.2.final) to create PDF documents. I'm currently running into a problem which I could use some help with.
I have one master report which contains 3 subreports. Each of the subreports is full fledged document with their own header, detail and (last)pageFooter band. Each of the subreports are created in their own detail band with pagebreak so they each subreports start on a new page. So far there aren't any issues.
Now the customer wants a page number on every page on a specific place in the document, this place corresponds to a specific part of the header of each of the subreports. See the image below:
Location of the pagenumber http://puu.sh/dAZzg/edaa1285c4.png
What I did to enable this is create a pageHeader in the master report which contains the pageNumber. Then I gave each of the subreports a negative y-coordinate so they slide over the pageHeader thus printing the pageNumber on exactly the right location. This works partially.
<pageHeader>
<band height="159">
<property name="local_mesure_unitheight" value="cm"/>
<textField>
<reportElement x="483" y="145" width="31" height="14" uuid="f512ea15-2e4b-4c63-bf92-61b990d9c461">
<property name="local_mesure_unitheight" value="cm"/>
<property name="com.jaspersoft.studio.unit.height" value="cm"/>
<property name="local_mesure_unity" value="cm"/>
<property name="com.jaspersoft.studio.unit.y" value="cm"/>
</reportElement>
<textElement textAlignment="Left">
<font fontName="Amerigo BT"/>
</textElement>
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<detail>
<band height="83" splitType="Stretch">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
<subreport>
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="-56" y="-175" width="573" height="83" uuid="5e4141a0-ac50-485a-8269-40b607c67466">
<property name="local_mesure_unity" value="cm"/>
<property name="com.jaspersoft.studio.unit.y" value="cm"/>
<property name="local_mesure_unitx" value="cm"/>
<property name="com.jaspersoft.studio.unit.x" value="cm"/>
</reportElement>
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("//idbfyl:fiscalYearReportLetter")]]></dataSourceExpression>
<subreportExpression><![CDATA["FiscalYearReportLetter.jasper"]]></subreportExpression>
</subreport>
</band>
<band height="83" splitType="Stretch">
<break>
<reportElement x="0" y="0" width="513" height="1" uuid="43e0cd6d-cc0b-4ce9-ae2f-0d8d2b498896"/>
</break>
<subreport>
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="-56" y="-175" width="573" height="70" uuid="df524b80-9db1-43b7-9c45-3b8ea21c8081">
<property name="local_mesure_unity" value="cm"/>
<property name="com.jaspersoft.studio.unit.y" value="cm"/>
</reportElement>
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("//idbfyvr:fiscalYearValueReport")]]></dataSourceExpression>
<subreportExpression><![CDATA["FiscalYearValueReport.jasper"]]></subreportExpression>
</subreport>
</band>
<band height="83" splitType="Stretch">
<break>
<reportElement x="0" y="0" width="513" height="1" uuid="bcddb440-2fdd-49c2-98cc-7978260c8d34"/>
</break>
<subreport>
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="-56" y="-175" width="573" height="70" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" uuid="df524b80-9db1-43b7-9c45-3b8ea21c8081">
<property name="local_mesure_unity" value="cm"/>
<property name="com.jaspersoft.studio.unit.y" value="cm"/>
</reportElement>
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("//ibdfyir:fiscalYearIncomeReport")]]></dataSourceExpression>
<subreportExpression><![CDATA["FiscalYearIncomeReport.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
Every first page of a subreports prints on the correct location, but on every page after the first one the subreport is printed below the pageHeader, it seems like the negative y coordinate is reset to 0.
Is there a way to force every page of a subreport to start from the same negative y-coordinate, or is there another way to achieve what I need?
Cheers,
Rick
PS. The example pictures start from page 2 because the first subreport only consists of 1 page. I've also removed sensitive data from the screenshot so don't worry about the white spaces you see.
I had similar problem. Try to place the pageNumber in the details band of the master report and mark it isPrintWhenDetailOverFlows to get pageNumber to print on all pages when subreport overflows.