Meaningless Drivel is fun!
The moose likes Other Open Source Projects and the fly likes jasper report to PDF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "jasper report to PDF" Watch "jasper report to PDF" New topic

jasper report to PDF

sajeevi bangamuwage

Joined: Jan 19, 2005
Posts: 21
This is th programe i 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.

// 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);


catch (JRException e)

// Exception handling for the Class.forName method.
catch (ClassNotFoundException ex)

// Exception handling for the DriverManager.getConnection method.
catch (SQLException ex)


runtime error

Exception in thread "main" java.lang.NoClassDefFoundError: com/lowagie/text/DocumentException
at net.sf.jasperreports.engine.JasperExportManager.exportReportToPdfFile(
at jasperreportsdemoapp.Main.main(
Java Result: 1 }
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
For generating PDFs Jasper uses the iText library; it seems that the iText jar file is missing from your classspath.
Sindhu bs

Joined: Feb 18, 2008
Posts: 7
I hav the same problem.I tried adding the jar to classpath but still problem persists please help!!!Im disgusted!!
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

"Sindhu bs",
Please check your private messages regarding an important administrative matter.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: jasper report to PDF
It's not a secret anymore!