[英]NoClassDefFoundError: com/itextpdf/text/DocumentException when exporting jasper to pdf
I created a jasper
report and now I need to export that report to pdf
format. 我创建了一个
jasper
报告,现在我需要将该报告导出为pdf
格式。 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. 当我使用
JasperViewer
查看报告时,它工作正常。 But When I exporting the report into pdf
format, it gives me the following exception. 但是,当我将报告导出为
pdf
格式时,出现以下异常。
Exception in thread "main" java.lang.NoClassDefFoundError: com/itextpdf/text/DocumentException
But I have put the iText jar into my libraries. 但是我已经将iText jar放入了我的库中。
But one thing, I had another version of iText
jar before. 但是有一件事,我之前有另一个版本的
iText
jar。 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).
我以为它的版本可能有问题(我遵循了一个教程,所以我添加了与教程中使用的相同的jar替换了我使用的新jar)。
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. 我删除了整个库,并使用本教程使用的
iText
jar再次添加了它。 But I had no luck. 但是我没有运气。
Could you please help me to overcome this issue. 您能帮我解决这个问题吗? Thank you!
谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.