我正在尝试执行以下代码。但得到这个例外:
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());
}