Jump to content
Changes to the Jaspersoft community edition download ×

Single Report file with embedded subreports

Recommended Posts

By: Peter Henderson - phenderson

Single Report file with embedded subreports

2003-08-19 15:40

I need to compile a report which contains subreports into a single .japser file, with no external dependancies.


My current solution is to convert the subreports .japer files into

new ByteArrayInputStream( new byte[]{-84,-19,0,5,115,114 .... )


and use java.io.Inputstream as my Subreport expression type.


This works, but Im sure im missing an easier solution.

As a down side, this method turns 2 20k japers files into a 300k jasper file, not ideal + it slows down report filling.






code to convet a jasper file into a byte array input stream.

String subreportFilename = "contact_category_subreport.jasper";

StringBuffer data = new StringBuffer(50000);

try {

FileInputStream fis = new FileInputStream(subreportFilename );

data.append( "new ByteArrayInputStream( new byte[]{" );

int count=0;

int bt = -1;

while( (bt=fis.read())!=-1 ) {

byte bb = (byte)bt;

data.append( Byte.toString(bb) ); // Integer.toString(bt) );



if( count%80==0 ) {





} catch(Exception e) {

System.err.println("Failed " + e );


System.out.println("Data=" + data);

Link to comment
Share on other sites

  • Replies 0
  • 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...