Search code examples
javapdfitextitext7

IText pdf reader throwing exception "IndexOutOfBoundsException"


I am using IText pdf reader to read pdf file but for few of the pdf file I am getting "IndexOutOfBoundsException".

below is the code

com.itextpdf.text.pdf.PdfReader reader = new com.itextpdf.text.pdf.PdfReader(file.getPath());

Exception I am getting : java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 9854 but can able to open the pdf file with other applications.

I tried with stream as well but getting same error.

Suggest how I can fix the issue.


Solution

  • Upon all the try I found out the issue of getting exception. It is because of the iText API bug in its version 5.1 and when I rebuilt my application with the latest version 5.5.x.x I get no exception and every thing works fine :)

    Getting Answer From:

    how to get out of String index out of range: -1 in iText