Buenos días,
estoy intentando añadir una tabla a mi pdf con la librería iText:
Document documento = new Document();
FileOutputStream ficheroPdf = new FileOutputStream("fichero.pdf");
PdfWriter.getInstance(documento,ficheroPdf).setIni tialLeading(20);
documento.open();
PdfPTable table = new PdfPTable(2);
PdfPCell celda1 = new PdfPCell(new Phrase ("Nombre:"));
celda1.setBorderColor(BaseColor.BLUE);
table.addCell(celda1);
PdfPCell celda2= new PdfPCell(new Phrase ("Apellido:"));
celda2.setBorderColor(BaseColor.RED);
table.addCell(celda2);
documento.add(table)
documento.close();
Me sale el siguiente error:
19:30:39,627 ERROR [http-bio-8080-exec-21][PortletServlet:116] javax.portlet.PortletException: java.lang.NoSuchMethodError: com.itextpdf.text.pdf.PdfPTable.addCell(Lcom/itextpdf/text/pdf/PdfPCell;)Lcom/itextpdf/text/pdf/PdfPCell;
javax.portlet.PortletException: java.lang.NoSuchMethodError: com.itextpdf.text.pdf.PdfPTable.addCell(Lcom/itextpdf/text/pdf/PdfPCell;)Lcom/itextpdf/text/pdf/PdfPCell;
at com.liferay.portal.kernel.portlet.LiferayPortlet.c allActionMethod(LiferayPortlet.java:166)
at com.liferay.util.bridges.mvc.MVCPortlet.callAction Method(MVCPortlet.java:247)
at com.liferay.portal.kernel.portlet.LiferayPortlet.p rocessAction(LiferayPortlet.java:78)
at com.liferay.util.bridges.mvc.MVCPortlet.processAct ion(MVCPortlet.java:210)
at com.liferay.portlet.FilterChainImpl.doFilter(Filte rChainImpl.java:71)
at com.liferay.portal.kernel.portlet.PortletFilterUti l.doFilter(PortletFilterUtil.java:48)
at com.liferay.portal.kernel.servlet.PortletServlet.s ervice(PortletServlet.java:112)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:728)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
at com.liferay.portal.kernel.servlet.filters.invoker. InvokerFilterChain.doFilter(InvokerFilterChain.jav a:116)
at com.liferay.portal.kernel.servlet.filters.invoker. InvokerFilter.doFilter(InvokerFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.inv oke(ApplicationDispatcher.java:749)
at org.apache.catalina.core.ApplicationDispatcher.doI nclude(ApplicationDispatcher.java:605)
at org.apache.catalina.core.ApplicationDispatcher.inc lude(ApplicationDispatcher.java:544)
at com.liferay.portlet.InvokerPortletImpl.invoke(Invo kerPortletImpl.java:583)
at com.liferay.portlet.InvokerPortletImpl.invokeActio n(InvokerPortletImpl.java:628)
at com.liferay.portlet.InvokerPortletImpl.processActi on(InvokerPortletImpl.java:308)
at com.liferay.portlet.PortletContainerImpl._doProces sAction(PortletContainerImpl.java:402)
at com.liferay.portlet.PortletContainerImpl.processAc tion(PortletContainerImpl.java:110)
at com.liferay.portlet.SecurityPortletContainerWrappe r.processAction(SecurityPortletContainerWrapper.ja va:109)
at com.liferay.portlet.RestrictPortletContainerWrappe r.processAction(RestrictPortletContainerWrapper.ja va:75)
at com.liferay.portal.kernel.portlet.PortletContainer Util.processAction(PortletContainerUtil.java:115)
at com.liferay.portal.action.LayoutAction.processLayo ut(LayoutAction.java:378)
at com.liferay.portal.action.LayoutAction.doExecute(L ayoutAction.java:200)
at com.liferay.portal.action.LayoutAction.execute(Lay outAction.java:95)
at org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:236)
at com.liferay.portal.struts.PortalRequestProcessor.p rocess(PortalRequestProcessor.java:178)
at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:647)
at com.liferay.portal.servlet.MainServlet.callParentS ervice(MainServlet.java:549)
at com.liferay.portal.servlet.MainServlet.service(Mai nServlet.java:526)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:728)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
at com.liferay.portal.kernel.servlet.filters.invoker. InvokerFilterChain.doFilter(InvokerFilterChain.jav a:116)
at com.liferay.portal.kernel.servlet.BaseFilter.proce ssFilter(BaseFilter.java:169)
at com.liferay.portal.servlet.filters.secure.SecureFi lter.processFilter(SecureFilter.java:293)
at com.liferay.portal.kernel.servlet.BaseFilter.doFil ter(BaseFilter.java:59)
at com.liferay.portal.kernel.servlet.filters.invoker. InvokerFilterChain.processDoFilter(InvokerFilterCh ain.java:204)
at com.liferay.portal.kernel.servlet.filters.invoker. InvokerFilterChain.doFilter(InvokerFilterChain.jav a:109)
at com.liferay.portal.kernel.servlet.BaseFilter.proce ssFilter(BaseFilter.java:169)
at com.liferay.portal.servlet.filters.jsoncontenttype .JSONContentTypeFilter.processFilter(JSONContentTy peFilter.java:42)
at com.liferay.portal.kernel.servlet.BaseFilter.doFil ter(BaseFilter.java:59)
at com.liferay.portal.kernel.servlet.filters.invoker. InvokerFilterChain.processDoFilter(InvokerFilterCh ain.java:204)
at com.liferay.portal.kernel.servlet.filters.invoker. InvokerFilterChain.doFilter(InvokerFilterChain.jav a:109)
at com.liferay.portal.kernel.servlet.filters.invoker. InvokerFilter.doFilter(InvokerFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.inv oke(ApplicationDispatcher.java:749)
at org.apache.catalina.core.ApplicationDispatcher.pro cessRequest(ApplicationDispatcher.java:487)
at org.apache.catalina.core.ApplicationDispatcher.doF orward(ApplicationDispatcher.java:412)
at org.apache.catalina.core.ApplicationDispatcher.for ward(ApplicationDispatcher.java:339)
at com.liferay.portal.servlet.FriendlyURLServlet.serv ice(FriendlyURLServlet.java:156)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:728)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
at com.liferay.portal.kernel.servlet.filters.invoker. InvokerFilterChain.doFilter(InvokerFilterChain.jav a:116)
at com.liferay.portal.kernel.servlet.BaseFilter.proce ssFilter(BaseFilter.java:169)
at com.liferay.portal.servlet.filters.strip.StripFilt er.processFilter(StripFilter.java:359)
at com.liferay.portal.kernel.servlet.BaseFilter.doFil ter(BaseFilter.java:59)
at com.liferay.portal.kernel.servlet.filters.invoker. InvokerFilterChain.processDoFilter(InvokerFilterCh ain.java:204)
at com.liferay.portal.kernel.servlet.filters.invoker. InvokerFilterChain.doFilter(InvokerFilterChain.jav a:109)
at com.liferay.portal.kernel.servlet.BaseFilter.proce ssFilter(BaseFilter.java:169)
at com.liferay.portal.servlet.filters.gzip.GZipFilter .processFilter(GZipFilter.java:123)
at com.liferay.portal.kernel.servlet.BaseFilter.doFil ter(BaseFilter.java:59)
at com.liferay.portal.kernel.servlet.filters.invoker. InvokerFilterChain.processDoFilter(InvokerFilterCh ain.java:204)
at com.liferay.portal.kernel.servlet.filters.invoker. InvokerFilterChain.doFilter(InvokerFilterChain.jav a:109)
at com.liferay.portal.kernel.servlet.BaseFilter.proce ssFilter(BaseFilter.java:169)
at com.liferay.portal.servlet.filters.secure.SecureFi lter.processFilter(SecureFilter.java:293)
at com.liferay.portal.kernel.servlet.BaseFilter.doFil ter(BaseFilter.java:59)
at com.liferay.portal.kernel.servlet.filters.invoker. InvokerFilterChain.processDoFilter(InvokerFilterCh ain.java:204)
at com.liferay.portal.kernel.servlet.filters.invoker. InvokerFilterChain.doFilter(InvokerFilterChain.jav a:109)
Caused by: java.lang.NoSuchMethodError: com.itextpdf.text.pdf.PdfPTable.addCell(Lcom/itextpdf/text/pdf/PdfPCell;)Lcom/itextpdf/text/pdf/PdfPCell;
at com.servihabitat.action.FormularioFondoSocialActio n.generarPdf(FormularioFondoSocialAction.java:466)
at com.servihabitat.action.FormularioFondoSocialActio n.anadir(FormularioFondoSocialAction.java:374)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.liferay.portal.kernel.portlet.LiferayPortlet.c allActionMethod(LiferayPortlet.java:148)
... 129 more
Parece que no reconoce el método de añadir la celda, he vuelto a instalar el jar de itext por si estaba dañado pero nada, cómo puedo solucionarlo??
Gracias.
Saludos!