我正在尝试执行下面的代码。但是得到这个异常:
java.lang.IndexOutOfBoundsException:索引: 11,大小: 11
有没有人知道是什么导致了这个异常以及如何解决它?
private ByteArrayInputStream getByteArrayInputStream(Document doc) throws DocumentException, IOException {
InputStream pdfStream = new ByteArrayInputStream(doc.html().getBytes());
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
com.itextpdf.text.Document document = new com.itextpdf.text.Document(PageSize.LETTER);
PdfWriter writer = PdfWriter.getInstance(document, bytesOut);
document.open();
try{
XMLWorkerHelper.getInstance().parseXHtml(writer, document, pdfStream, Charset.forName("UTF-8"));
}
catch(IOException ioe){
System.out.println(ioe.getMessage());
ioe.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}
document.close();
return new ByteArrayInputStream(bytesOut.toByteArray());
}发布于 2017-06-21 15:42:55
我也有同样的例外。Itext renderer.layout()在处理空表行时存在问题:
自动关闭的<tr/>会在表中造成麻烦。如果可能,请选择此结构:<tr><td></td></tr>
https://stackoverflow.com/questions/40668003
复制相似问题