2016-11-18 169 views
0

我想执行下面的代码。但是,得到此异常:XMLWorkerHelper异常java.lang.IndexOutOfBoundsException:索引:11,大小:11

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()); 
    } 
+0

现在,这会发生什么呢? –

+0

试图将文档转换为pdf .. – Ashwini

+0

不,在上面发布的代码在哪里发生?如何发布你的stacktrace以及。 –

回答

0

我有同样的例外。 Itext renderer.layout()在空表行存在问题:

自动关闭<tr/>在表中产生问题。请选择如果可能这种结构代替:<tr><td></td></tr>

相关问题