Jump to content
We've recently updated our Privacy Statement, available here ×

export to pdf creates balnk page


greenf
Go to solution Solved by lucianc,

Recommended Posts

I've try to create pdf from jrxml inside StringBuffer. I do it by converting Stringbuffer -> String -> bytes[] -> ByteArrayInputStream -> JasperCompileManager.compileReport( stream )

 

It creates balnk file.

However, if I write stream to the file and try to convert file to pdf, it works fine.

 

Is anybody can tell me what the reason of this.

Code:
        byte[] bytes = buf.toString().getBytes();
InputStream stream = new ByteArrayInputStream( bytes );

//Convert stream to Jasper Report and JasperReport to PDF
JasperReport jasperReport;
JasperPrint jasperPrint;
StringBuffer result;
try {
jasperReport = JasperCompileManager.compileReport( stream );
jasperPrint =
JasperFillManager.fillReport(
jasperReport, new HashMap(), new JREmptyDataSource() );
bytes = JasperExportManager.exportReportToPdf( jasperPrint );
result = new StringBuffer( new String( bytes) );
LOG.info( "Summary file created rn" );
} catch (JRException e) {
result = new StringBuffer();
LOG.info( "Summary creation failed rn" + e );
}
buf = new StringBuffer();
return result;
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...