Jump to content
Changes to the Jaspersoft community edition download ×

creating report from stream


greenf

Recommended Posts

I want to create report from stream. I take content of jrxml file that works, put it in String, convert it to ByteArrayInputStream and use stream as source of JasperCompileManager.compileReport(). It throws exception with message :

Element bottom reaches outside band area : y=0 height=20 band-height=0

 

Increasing/Decreasing height attribute don't help.

 

Code:

//build string with JasperReport xml inside
StringBuffer buf =
new StringBuffer(
"<?xml version="1.0"?>n" +
"<!DOCTYPE jasperReportn" +
" PUBLIC "-//JasperReports//DTD Report Design//EN"n" +
" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">n" );
buf.append( "<jasperReport name="Simple_Report">n" );
buf.append( "<detail>n" );
buf.append( "<band>n" );
buf.append( "<staticText>n" );
buf.append( "<reportElement x="180" y="0" width="200" height="50"/>n" );
buf.append( "<text><![CDATA[Hello word!]]></text>n" );
buf.append( "</staticText>n" );
buf.append( "</band>n" );
buf.append( "</detail>n" );
buf.append( "</jasperReport>n" );

//Convert buffer to stream
byte[] bytes = buf.toString().getBytes();
InputStream stream = new ByteArrayInputStream( bytes );

//Convert stream to Jasper Report and JasperReport to PDF
try {
jasperReport = JasperCompileManager.compileReport( stream );
jasperPrint =
JasperFillManager.fillReport(
jasperReport, new HashMap(), new JREmptyDataSource() );
//jasperPrint = JRPrintXmlLoader.load( "jasperreports_demo.jrxml" );
JasperExportManager.exportReportToPdfFile(
jasperPrint, "simple_report2.pdf" );
} catch (JRException e) {
e.printStackTrace();
}
Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...