Dear Users,

 

I am trying to convert a String object having HTML content to PDF document. But the code throws an exception saying

 

DocumentException: java.lang.IndexOutOfBoundsException: Index: 7, Size: 7

 

Here is my code….

 

      String htmlOP = “<html></html>”; // Some html content

 

      ByteArrayInputStream bais = new ByteArrayInputStream(htmlOP.getBytes());

 

      // OutputStream which will contain output pdf data

      ByteArrayOutputStream  baos = new ByteArrayOutputStream();

           

      //PDFWriter to get PDF output

      PdfWriter.getInstance(document, baos);

     

      //This html will be parsed with the byte array input stream and set into document.

      HtmlParser.parse(document, bais);

 

-------------------------------------------------------------------------

 

Exception reported…

 

Index: 7, Size: 7

ExceptionConverter: ExceptionConverter: DocumentException: java.lang.IndexOutOfBoundsException: Index: 7, Size: 7

      at org.apache.crimson.parser.Parser2.parseInternal(Unknown Source)

      at org.apache.crimson.parser.Parser2.parse(Unknown Source)

      at org.apache.crimson.parser.XMLReaderImpl.parse(Unknown Source)

      at javax.xml.parsers.SAXParser.parse(Unknown Source)

      at com.lowagie.text.html.HtmlParser.go(Unknown Source)

      at com.lowagie.text.html.HtmlParser.parse(Unknown Source)

      at PDF.main(PDF.java:46)

 

Please give me your comments.

 

Thanks and regards

 

Mazhar Shaikh

Handy: +91 98606.87474

This email may contain confidential or privileged information for the intended recipient(s) and the views expressed in the same are not necessarily the views of Zensar Technologies Ltd. If you are not the intended recipient or have received this     e-mail by error, its use is strictly prohibited, please delete the e-mail and notify the sender. Zensar Technologies Ltd. does not accept any liability for virus infected mails.

_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to