File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Error when exportReportToPdfFile Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Error when exportReportToPdfFile" Watch "Error when exportReportToPdfFile" New topic
Author

Error when exportReportToPdfFile

vasu hk
Greenhorn

Joined: Oct 29, 2009
Posts: 2
Hi,
I have used the code fragment mentioned below to view the report and export to PDFfile in NetBeans 6.1 (the report is originally generated and compiled using iReport 3.6.0),my requirement is to export in to pdf using jsp application ,i have used the latest iText2.1.0 jar file in my application ,still i getting the exception , please help me .


code:

public class ReportServlet extends HttpServlet {
Connection con;
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println("bb");

ServletOutputStream servletOutputStream = response.getOutputStream();

try {
Class.forName("org.postgresql.Driver");
con = DriverManager.getConnection("jdbc:postgresql://localhost:5444/das", "postgres" , "postgres");

} catch (Exception e) {
}




try {

System.out.println("Calling .....");

String home_path=System.getProperty("user.home");
ServletContext ctx = getServletContext();
String realpath_paydts=ctx.getRealPath("/Jasper");

System.out.println("path :::"+realpath_paydts);
Map parameters = new HashMap();


parameters.put("fdate", new java.util.Date(10/10/2004));
parameters.put("tdate", new java.util.Date(11/11/2009));
parameters.put("cc_code", new String("1"));
parameters.put("fqty",new java.lang.Double(1.0d));
parameters.put("tqty", new java.lang.Double(9.0d));

JasperReport jasperReport;
JasperPrint jasperPrint;
JasperDesign jasperDesign;



try{
jasperDesign =JRXmlLoader.load(realpath_paydts+"/Datewisecollection.jrxml");

jasperReport =JasperCompileManager.compileReport(jasperDesign);


jasperPrint = JasperFillManager.fillReport(jasperReport,parameters, con );
JasperViewer.viewReport(jasperPrint, false);

JasperExportManager.exportReportToPdfFile(jasperPrint,home_path+"/Datewisecollection.pdf");


} catch(Exception ex) { }

servletOutputStream.flush();
servletOutputStream.close();

}catch(Exception ex)
{
ex.printStackTrace();
}
}




Exception:

javax.servlet.ServletException: Servlet execution threw an exception

java.lang.NoSuchMethodError: com.lowagie.text.pdf.PdfWriter.setRgbTransparencyBlending(Z)V
net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:480)
net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:379)
net.sf.jasperreports.engine.JasperExportManager.exportReportToPdfFile(JasperExportManager.java:122)
ReportServlet.processRequest(ReportServlet.java:104)
ReportServlet.doGet(ReportServlet.java:142)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9321
    
  17

vasu please Use Code Tags when you post a source code. You can edit your message using button and then add code tags to it.

There seems to be a method named setRgbTransparencyBlending as given here. Are you using two sets of libraries?? If yes, make sure that they are compatible with each other. Also make sure that the library is getting packaged in your application so that it's available at runtime...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error when exportReportToPdfFile