I created a jasper
report and now I need to export that report to pdf
format. This is my code for that.
// compiles jrxml
JasperCompileManager.compileReportToFile(reportName + ".jrxml");
// fills compiled report with parameters and a connection
JasperPrint print = JasperFillManager.fillReport(reportName + ".jasper", parameters, connection);
// to view the report
//JasperViewer.viewReport(print, false);
// export repor to pdf
JasperExportManager.exportReportToPdfFile(print, "fromXml.pdf");
When I view the report using JasperViewer
, it works fine. But When I exporting the report into pdf
format, it gives me the following exception.
Exception in thread "main" java.lang.NoClassDefFoundError: com/itextpdf/text/DocumentException
But I have put the iText jar into my libraries.
But one thing, I had another version of iText
jar before. It gave me the same exception. I thought that there may be some issues with the version of it.(I followed a tutorial, so I added the same jar as they had used in the tutorial replacing the new jar I had used).
but still the problem remains. I thought this may be the issue now(the accepted answer of the question). But I do not know how to fix it. I removed the entire library and added it again with iText
jar which had been used by the tutorial. But I had no luck.
Could you please help me to overcome this issue. Thank you!