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

pdf has no pages


Recommended Posts

By: ainhoa - sorgin

pdf has no pages

2003-05-22 01:02

Hi!

 

I try to get a pdf report, if a write it in the disk the report is perfect, but if I try to export it to a Stream, y get this error:

ExceptionConverter: java.io.IOException: The document has no pages. at com.lowagie.text.pdf.PdfPages.writePageTree(Unknown Source) at com.lowagie.text.pdf.PdfWriter.close(Unknown Source) at com.lowagie.text.pdf.PdfDocument.close(Unknown Source) at com.lowagie.text.Document.close(Unknown Source) at dori.jasper.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:345) at dori.jasper.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:262) at servlets.PdfServlet.service(PdfServlet.java:52) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at ...

 

This is the code, but I have try is with several methods:

 

ServletContext context = this.getServletConfig().getServletContext();

 

File reportFile = new File(context.getRealPath("/reports/CptReport.jrprint"));

JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(reportFile.getPath());

ByteArrayOutputStream baos = new ByteArrayOutputStream();

 

JRPdfExporter exporter = new JRPdfExporter();

exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);

exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);

exporter.exportReport();

if(baos.size() > 0)

{

System.out.print("en baos hay algo");

}

else

{

System.out.print("en baos no hay nada");

}

 

//PAra indicar el MIME

respuesta.setContentType("application/pdf");

// PAra indicarle que queremos abrirlo con el Acrobat

// Y el nombre con el que queremos guardarlo

 

respuesta.setHeader("Content-disposition",

"attachment; filename=" +

"CptInforme.pdf" );

 

respuesta.setContentLength(baos.size());

 

ServletOutputStream outStream = respuesta.getOutputStream();

 

baos.writeTo(outStream);

outStream.flush();

outStream.close();

}

 

The jasperPrint has data, and is ok, what is the problem, thank you,

 

 

 

 

 

 

By: ainhoa - sorgin

RE: pdf has no pages

2003-05-22 01:57

I went back to iText 0.96, and I solve my problem

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