This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have David & Dawn Griffiths on-line!
See this thread for details.
Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

jasper report to PDF

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is th programe i write.it is work for html format. but it does not work for PDF format. ir gives runtime error.I have given the error below.can you please help me to solve this.


package jasperreportsdemoapp;

import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.view.JasperViewer;


public class Main {


public static void main(String[] args) {

String reportSource = "./report/templates/HelloReportWorld.jrxml";

// String reportDest = "./report/results/HelloReportWorld.html";

//****************
String reportDest = "./report/results/HelloReportWorld.pdf";//****************


Map<String, Object> params = new HashMap<String, Object>();
params.put("reportTitle", "Hello Report World");
params.put("author", "Craig Conover");
params.put("startDate", (new java.util.Date()).toString());


try {
JasperReport jasperReport = JasperCompileManager.compileReport(reportSource);

// Make the driver class available.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

// Create a connection to pass into the report.
java.sql.Connection conn = DriverManager.getConnection("jdbc dbc SN_ics","ics","ics");

// Replace the empty JR datasource parameter with
// the connection parameter named conn.
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, conn);

//JasperExportManager.exportReportToHtmlFile(jasperPrint, reportDest);

//*************
JasperExportManager.exportReportToPdfFile(jasperPrint, reportDest);
//*************

JasperViewer.viewReport(jasperPrint);
}

catch (JRException e)
{
e.printStackTrace();
}

// Exception handling for the Class.forName method.
catch (ClassNotFoundException ex)
{
ex.printStackTrace();
}

// Exception handling for the DriverManager.getConnection method.
catch (SQLException ex)
{
ex.printStackTrace();
}

}
}

runtime error

run:
Exception in thread "main" java.lang.NoClassDefFoundError: com/lowagie/text/DocumentException
at net.sf.jasperreports.engine.JasperExportManager.exportReportToPdfFile(JasperExportManager.java:121)
at jasperreportsdemoapp.Main.main(Main.java:66)
Java Result: 1 }
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For generating PDFs Jasper uses the iText library; it seems that the iText jar file is missing from your classspath.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I hav the same problem.I tried adding the jar to classpath but still problem persists please help!!!Im disgusted!!
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Sindhu bs",
Please check your private messages regarding an important administrative matter.
-Ben
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic