Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error when exportReportToPdfFile

 
vasu hk
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic