Jump to content
Changes to the Jaspersoft community edition download ×

PDF Export help needed! :)


Recommended Posts

By: finzic - finzic

PDF Export help needed! :)

2006-03-28 08:01

Hi all,

I have a JasperPrint obj (this.jp) in my app that works fine since it can be printed or displayed as a preview.

 

I need to export it to PDF file, so I tried to follow the demo code:

 

JasperExportManager.exportReportToPdfFile(this.jp, "myFile.pdf");

 

but what I get is:

ExceptionConverter: java.lang.NullPointerException

 

at com.lowagie.text.pdf.PdfDocument.close(Unknown Source)

 

at com.lowagie.text.Document.close(Unknown Source)

 

at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:438)

 

at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:278)

 

at net.sf.jasperreports.engine.JasperExportManager.exportReportToPdfFile(JasperExportManager.java:126)

 

at mycode.JReportBuilder.creaPDF(xxxxxxx)

 

 

Any suggestion here will be extremely important!

TIA,

Luca.

 

 

 

 

By: legion - cajinadiaz

RE: PDF Export help needed! :)

2006-03-28 08:11

Your application is a Web Application ??

 

 

 

 

By: legion - cajinadiaz

RE: PDF Export help needed! :)

2006-03-28 08:19

Anyway.. I have a Web Application and I'm using this code:

 

/*GENERATE THE OUTPUT AS PDF..*/

public void generatePDFOutput(

HttpServletResponse resp,

Map parameters,

JasperReport jasperReport)

throws JRException, NamingException, SQLException, IOException {

 

byte[] bytes =

JasperRunManager.runReportToPdf( jasperReport, parameters, getMyConnection());

resp.setContentType("application/pdf");

resp.setContentLength(bytes.length);

OutputStream ouputStream = resp.getOutputStream();

ouputStream.write(bytes, 0, bytes.length);

ouputStream.flush();

ouputStream.close();

}

 

 

 

 

 

By: finzic - finzic

RE: PDF Export help needed! :)

2006-03-29 07:00

Hi cajinadiaz,

I tried to follow your suggestion but it did not

work , I'm afraid: here's my code.

 

OutputStream os = new FileOutputStream("c:/ciao.pdf");

 

byte[] reportByteArray ;

JasperRunManager.

reportByteArray = JasperExportManager.exportReportToPdf(this.jp);

os.write(reportByteArray);

os.close();

 

... and this is what I got... always the same exception...

 

ExceptionConverter: java.lang.NullPointerException

 

at com.lowagie.text.pdf.PdfDocument.close(Unknown Source)

 

at com.lowagie.text.Document.close(Unknown Source)

 

at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:438)

 

at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:257)

 

at net.sf.jasperreports.engine.JasperExportManager.exportReportToPdf(JasperExportManager.java:188)

 

it seems it's the export in itself that doesn't succeed.

The object this.jp is the same JasperPrint I use after the above code to build the report preview so it is well-formed...

any further idea?

TIA! Luca.

 

 

 

 

By: finzic - finzic

RE: PDF Export help needed! :)

2006-03-31 23:13

Solved!

The problem was:

I had an old iText library version in my classpath that got referenced before newer v1.3.1!

Wiping away old lib got me shine!

 

Thanks!

Luca.

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