greenf Posted December 17, 2007 Share Posted December 17, 2007 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 More sharing options...
greenf Posted December 17, 2007 Author Share Posted December 17, 2007 Excuse for this post. I've have already found a bug. <band> in my Sting don't have height attribute, so it height is 0 and every element will be larget than it.Probably will be better if administrators will remove this post. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now