java JRpdfExporter 不工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7606023/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JRPdfExporter is not working
提问by JN_newbie
I have createad a report in jasper report, when i have wrote the code in servlet to export the report in pdf it is not displaying the report.
我在 jasper 报告中创建了一份报告,当我在 servlet 中编写代码以导出 pdf 报告时,它没有显示报告。
JRPdfExporter pdfExporter = new JRPdfExporter();
pdfExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
//OutputStream ouputStream = response.getOutputStream();
//pdfExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);
pdfExporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, "C:/reports/payment.pdf");
pdfExporter.exportReport();
Now during debugging when debugger came to at this line JRPdfExporter pdfExporter = new JRPdfExporter(); it simply goes in finally block rather in next line. I am stuck into this any solutions.
现在在调试过程中,当调试器来到这一行 JRpdfExporter pdfExporter = new JRpdfExporter(); 它只是进入 finally 块而不是下一行。我被困在这个任何解决方案中。
and the Exception is:
异常是:
java.lang.NoClassDefFoundError: com/lowagie/text/DocumentException
java.lang.ClassNotFoundException: com.lowagie.text.DocumentException
采纳答案by Rangi Lin
Your code looks fine, and It compiles and runs correctly. I suspect that problem is inside JasperPrint
. Make sure you actually complie a JasperPrint
from your JRXML file.
您的代码看起来不错,并且可以正确编译和运行。我怀疑问题出在里面 JasperPrint
。确保您确实JasperPrint
从 JRXML 文件中编译了 a 。
If you set an empty JasperPrint
into the JRPdfExporter
, it will still runs correctly, but will result an empty PDF file.
如果设置为空JasperPrint
进入JRPdfExporter
,它仍然可以正常运行,但会导致一个空的PDF文件。
Hope this help you locate the error.
希望这可以帮助您定位错误。
EDIT :
编辑 :
these Exception messages you provided are indicated that JVM can not locate DocumentException
, according to package name, that's a class from iText library, if you have used iText, make sure you have included iText in your classpath.
您提供的这些异常消息表明 JVM 无法DocumentException
根据包名找到iText 库中的类,如果您使用过 iText,请确保您已在类路径中包含 iText。
回答by mahesh
I think you are not included "iText-2.1.7.js2.jar" file to your classpath. First include mentioned file then it will work fine.
我认为您的类路径中没有包含“iText-2.1.7.js2.jar”文件。首先包含提到的文件然后它会正常工作。
Hope it will help to you.
希望对你有帮助。
回答by Anthony Pi?ero
回答by DON
Just include itext-1.2.jar
inside your class path.
只需包含itext-1.2.jar
在您的类路径中。
回答by Juan Rada
You have to add http://itextpdf.com/jar file
你必须添加http://itextpdf.com/jar 文件