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());
}
现在,这会发生什么呢? –
试图将文档转换为pdf .. – Ashwini
不,在上面发布的代码在哪里发生?如何发布你的stacktrace以及。 –