Hi, (sorry for my English, it's terrible)

If you try do this, maybe solve you problem:

JasperPrint jPrint = JasperFillManager.fillReport(reportFile.getPath(),parameters,con);

if(jPrint.getPages().size() > 0)
{
          //JasperExportManager.exportReportToPdf(jPrint);
            //or
           JRPdfExporter exporter = new JRPdfExporter();
            exporter.setParameter(JRExporterParameter.JASPER_PRINT jPrint);

           ByteArrayOutputStream baos = new ByteArrayOutputStream();
           exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);
           exporter.exportReport();
byte[] bytes = baos.toByteArray();
            .....

 }
else
{
   //empty report handler
}

[]'s


Meenakshi Singh wrote:

------------------------------------------------
Anybody.......PLEASE HELP me solve this problem.
------------------------------------------------


Hi all,

I am using      JasperPrint.getPages().size() to determine if the report has
data in it or not.

Depending on the result I m forwarding it to an error page if it doesn't
have data.

It works fine with html and excel format. However, if I am unable to use it
in my pdf report as in my pdf report it doesn't return a jasper print object
, it returns bytes.
Below is the code for my pdf servlet.

Would anybody please help me as to how can I determine if teh report has any
data or not in my pdf format.

Thanks & Regards,
Meenakshi.

                bytes =
                                JasperRunManager.runReportToPdf(
                                        reportFile.getPath(),
                                        parameters,
                                        con);



                        response.setContentType("application/pdf");
                        response.setContentLength(bytes.length);
                        ServletOutputStream ouputStream = 
response.getOutputStream();
                        ouputStream.write(bytes, 0, bytes.length);
                        ouputStream.flush();
                        ouputStream.close();


                }



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
jasperreports-questions mailing list
jasperreports-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jasperreports-questions



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
jasperreports-questions mailing list
jasperreports-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jasperreports-questions




--
Henrique Rogerio de Oliveira
Desenvolvedor de Software
W3S Solutions <www.w3s.com.br>
+55 11 4052-9376 Ramal: 302
+55 11 2626-7181 Ramal: 302
+55 16 3331-2125 Ramal: 302
+55 16 9777-7495
[EMAIL PROTECTED]



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
jasperreports-questions mailing list
jasperreports-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jasperreports-questions

Reply via email to