[#6446] - always 2 newline feeds at the end of a exported TEXT file

Category:
Bug report
Priority:
Normal
Status:
Feedback Requested
Project: Severity:
Major
Resolution:
Fixed
Component: Reproducibility:
Always
Assigned to:

When I export to:
- TEXT format
- and I use <property name="net.sf.jasperreports.export.text.line.separator" value="&#xD;&#xA;"/> as a report level property

This works fine, all lines are delimited with carriage return and newline.
But at the end of the file, always 2 newline feeds are added.
So, the last line has \r\n\n\n instead of \r\n :

od -c Blank_A4.txt
0000000 S t a t i c T e x t \r \n \n \n
0000017

Happens in the designer studio and also on the server.

JRXML:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.1.0.final using JasperReports Library version 5.5.1 -->
<!-- 2015-11-19T14:57:36 -->
<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="110" pageHeight="842" columnWidth="110" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" isIgnorePagination="true" uuid="7939610f-5bf7-402c-a69c-f34ca84e927b">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<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="net.sf.jasperreports.print.keep.full.text" value="true"/>
<property name="net.sf.jasperreports.text.truncate.at.char" value="true"/>
<property name="net.sf.jasperreports.export.text.character.height" value="15"/>
<property name="net.sf.jasperreports.export.text.character.width" value="10"/>
<property name="net.sf.jasperreports.export.text.page.width" value="155"/>
<property name="net.sf.jasperreports.export.text.trim.line.right" value="true"/>
<property name="net.sf.jasperreports.export.text.line.separator" value="&#xD;&#xA;"/>
<queryString>
<![CDATA[]]>
</queryString>
<detail>
<band height="15" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="110" height="15" uuid="462dec04-1b02-4c0c-88e0-b802e759d68f">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textFieldExpression><![CDATA["Static Text"]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>

AttachmentSize
Binary Data blank_a4-text.jrxml2.29 KB
v6.1.0
erwin_3's picture
Joined: Dec 30 2014 - 1:26am
Last seen: 6 years 4 months ago

6 Comments:

#1
  • Status:New» Feedback Requested
  • Assigned:nobody» teodord

Hi,

Those 2 newline characters at the end of the page are the default page separator.
In case a page separator is not specified, by default, the page separator is considered to be a double line separator.

I see that you have a report with only one page, because of the isIgnorePagination="true".
So maybe you were not interested in setting the page separator configuration property, similar to how you did for the line separator property.
If you add this property to your JRXML, the extra lines at the end of the page should go away:

<property name="net.sf.jasperreports.export.text.page.separator" value=""/>

If you need to do this for all your reports that are exported to text format, you can add this line to the jasperreports.properties file that is in the root package of your classpath:

net.sf.jasperreports.export.text.page.separator=

In JasperReports Server, this file is under WEB-INF/classes/jasperreports.properties

If you are using Jaspersoft Studio, this property could be set in preferences, but currently there is an issue with this ability to set a string property to empty string, so the workaround for Studio is to set the property as custom property in JRXML, as indicated above.

I hope this helps.
Teodor

#2
  • Resolution:Open» No Change Required
  • Status:Feedback Requested» Closed

Hi,

Feel free to reopen this if you have new information.

Thanks,
Teodor

#3
  • Resolution:No Change Required» Fixed

Hi,

Decided to inhibit the page separator after the last page. This will be part of the next release.

Thanks,
Teodor

#4
  • Assigned:nobody»

Hi,

Is there a way to set the page separator manually after the last page in R6.14.0?

Regards
Stefan

#5
  • Status:Closed» Feedback Requested
#6

The text exporter no longer writes the last page separator after the last page.

If you need that, one way to do it is to extend the exporter class in your code like this:

JRTextExporter exporter = new JRTextExporter() {
@Override
protected void exportReportToWriter() throws JRException, IOException {
super.exportReportToWriter();
writer.write(pageSeparator);
}
};

Regards,
Lucian

Feedback
randomness