程序执行Document.add(Element pdfPTable)的时候,如果pdfPTable内容小一般不会报错,一旦内容稍大,就会报空指针错误。
报错如下,哪位大神有碰到过的,求指教啊。
com.itextpdf.text.DocumentException: java.lang.NullPointerException at com.itextpdf.text.pdf.PdfDocument.add(PdfDocument.java:804) at com.itextpdf.text.Document.add(Document.java:278) at com.landray.kmss.qm.chart.util.concernCpl.ConcernCplDownloadController.processDownConcernPdf(ConcernCplDownloadController.java:284) at com.landray.kmss.qm.chart.common.actions.ConcernCplDownloadAction.downConcernPDF(ConcernCplDownloadAction.java:42) at sun.reflect.GeneratedMethodAccessor469.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274) at org.apache.struts.actions.LookupDispatchAction.execute(LookupDispatchAction.java:160) at com.landray.kmss.sys.config.loader.KmssStrutsRequestProcessor$2.execute(KmssStrutsRequestProcessor.java:96) at com.landray.kmss.third.pda.interfaces.ThirdPdaActionInterceptor.execute(ThirdPdaActionInterceptor.java:20) at com.landray.kmss.sys.config.loader.KmssStrutsRequestProcessor$2.execute(KmssStrutsRequestProcessor.java:99) at com.landray.kmss.sys.config.loader.KmssStrutsRequestProcessor.processActionPerform(KmssStrutsRequestProcessor.java:104) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) at javax.servlet.http.HttpServlet.service(HttpServlet.java:643) at javax.servlet.http.HttpServlet.service(HttpServlet.java:723) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:292) at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116) at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:79) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303) at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:143) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303) at com.landray.kmss.sys.authentication.integration.KmssProcessingFilterProxy$VirtualFilterChain.doFilter(KmssProcessingFilterProxy.java:125) at com.landray.kmss.third.pda.interfaces.ThirdPdaRedirectFilter.doFilter(ThirdPdaRedirectFilter.java:102) at com.landray.kmss.sys.authentication.integration.KmssProcessingFilterProxy$VirtualFilterChain.doFilter(KmssProcessingFilterProxy.java:128) at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:246) at com.landray.kmss.sys.authentication.integration.KmssProcessingFilterProxy$VirtualFilterChain.doFilter(KmssProcessingFilterProxy.java:128) at com.landray.kmss.sys.authentication.integration.KmssProcessingFilterProxy.doFilter(KmssProcessingFilterProxy.java:49) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303) at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:220) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303) at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:173) at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:120) at com.landray.kmss.web.filter.AcegiFilterToBeanProxy.doFilter(AcegiFilterToBeanProxy.java:35) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.landray.kmss.web.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:43) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:619) Caused by: java.lang.NullPointerException at com.itextpdf.text.pdf.PdfPCell.<init>(PdfPCell.java:237) at com.itextpdf.text.pdf.PdfPRow.splitRowspans(PdfPRow.java:811) at com.itextpdf.text.pdf.ColumnText.goComposite(ColumnText.java:1790) at com.itextpdf.text.pdf.ColumnText.go(ColumnText.java:883) at com.itextpdf.text.pdf.ColumnText.go(ColumnText.java:878) at com.itextpdf.text.pdf.ColumnText.go(ColumnText.java:867) at com.itextpdf.text.pdf.PdfDocument.addPTable(PdfDocument.java:2622) at com.itextpdf.text.pdf.PdfDocument.add(PdfDocument.java:745) ... 56 more
空指针的话应该不是数据量大的原因还是检查程序吧单步跟踪下
空指针的话应该不是数据量大的原因还是检查程序吧单步跟踪下
请问这个是否支持 pdf extraction 呢?要是的话,提取text和image都可以吗?我也遇到了这个问题,循环添加单元格时出了纰漏,导致最后document.add(PdfPTabletable)时出现空指针
一定要通过cell.addElement();来添加元素!这一步后面会调用
publicvoidsetTotalWidth(floattotalWidth){if(this.totalWidth!=totalWidth){this.totalWidth=totalWidth;this.totalHeight=0.0F;this.calculateWidths();this.calculateHeights();}}
这一步很重要,少了这一步后面才会空指针,
希望你们也是这个问题
Document.add(Element pdfPTable),我是把pdfPTable中内容拆分成多个 解决的:
Document.add(Element pdfPTable1)
Document.add(Element pdfPTable2)
Document.add(Element pdfPTable3)
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。