単純な PDF 生成に iText を使用しようとすると、テーブル要素で NotImplementedException が発生します。
TableRowElement.type() は new NotImplementedException() をスローするだけです...なぜ呼び出されるのですか?
com.itextpdf.tool.xml.exceptions.NotImplementedException
at com.itextpdf.tool.xml.html.table.TableRowElement.type(TableRowElement.java:148)
at com.itextpdf.text.pdf.ColumnText.addElement(ColumnText.java:471)
at com.itextpdf.text.pdf.PdfPCell.addElement(PdfPCell.java:284)
at com.itextpdf.tool.xml.html.table.TableData.end(TableData.java:151)
at com.itextpdf.tool.xml.html.AbstractTagProcessor.endElement(AbstractTagProcessor.java:189)
at com.itextpdf.tool.xml.pipeline.html.HtmlPipeline.close(HtmlPipeline.java:206)
at com.itextpdf.tool.xml.XMLWorker.endElement(XMLWorker.java:141)
at com.itextpdf.tool.xml.parser.XMLParser.endElement(XMLParser.java:395)
at com.itextpdf.tool.xml.parser.state.ClosingTagState.process(ClosingTagState.java:70)
at com.itextpdf.tool.xml.parser.XMLParser.parseWithReader(XMLParser.java:235)
at com.itextpdf.tool.xml.parser.XMLParser.parse(XMLParser.java:213)
at com.itextpdf.tool.xml.XMLWorkerHelper.parseXHtml(XMLWorkerHelper.java:175)
at com.slim.pims.upload.ui.OwnerMainPDF.doPost(OwnerMainPDF.java:90)
at com.slim.pims.upload.ui.OwnerMainPDF.doGet(OwnerMainPDF.java:53)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
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:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
ソース:
//now, this is fun!
public boolean process(final ElementListener listener) {
throw new NotImplementedException();
}
public int type() {
throw new NotImplementedException();
}
public boolean isContent() {
throw new NotImplementedException();
}
public boolean isNestable() {
throw new NotImplementedException();
}
public List<Chunk> getChunks() {
throw new NotImplementedException();
}
HTMLソースを含めるように編集します。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<table style="width: 100%; ">
<tr>
<td>
<tr>
<td align="left" width="40%" valign="top">
<table id='tableRegionTotals' style='width: 100%;' border='0' cellpadding='0' cellspacing='1' bgcolor='#cccccc'><tr height='20'><td class='a5' align='center' width=40%;><stong>Schedule Status</stong></td><td class='a5' align='center' width=30%;><stong>No.</stong></td><td class='a5' align='center' width=30%;><stong>Total (for New Projects)</stong></td></tr><tr height='20'><td class='a0' align='left'><table><tr><td width=10%;> </td><td class='a0' width=90%;><div id='divOnTrack' style='width:10px;background-color:#336633;' > <a onclick='' name='nontrack'>On Track </a></div></td></tr></table></td><td class='a0' align='right'>1 </td><td class='a0' align='right'>0.00 </td></tr><tr height='20'><td class='a0' align='left'><table><tr><td width=10%;> </td><td class='a0' width=90%;><div id='divNeedsAttention' style='width:10px;background-color:#cccc33;' > <a onclick='' name='nontrack'>Needs Attention </a></div></td></tr></table></td><td class='a0' align='right'>1 </td><td class='a0' align='right'>0.00 </td></tr><tr height='20'><td class='a0' align='left'><table><tr><td width=10%;> </td><td class='a0' width=90%;><div id='divOffTrack' style='width:10px;background-color:#cc0000;' > <a onclick='' name='nontrack'>Off Track </a></div></td></tr></table></td><td class='a0' align='right'>20 </td><td class='a0' align='right'>0 </td></tr></table>
</td>
<td width="1%"> </td>
<td align="right" width="55%" valign="top">
</td>
</tr>
</td>
</tr>
</table>
<table>
<tr>
<td>
</td>
</tr>
</table>
</body>
</html>