Hi all ,

* I am very long time user of PDFBOX from 0.7.3 version.

* Current I am using the latest version(1.5.0).

* While running a Malformed PDF i came across ArrayIndexOutOfBound
Exception.

* I searched Mail archives i can not able to fix it .

* Finally I touched the code and made a slighter change. Now it is
extracting correct Page Numbers.

* Can you guide me if the method followed by me and the way i fix the bug is
correct.

* I attached the sample PDF with this mail .

*ORIGINAL CODE* *IN PDPageLabels.java

 *public String[] getLabelsByPageIndices()
    {
        final String[] map = new String[doc.getNumberOfPages()];
        computeLabels(new LabelHandler()
        {
            public void newLabel(int pageIndex, String label)
            {

                map[pageIndex] = label;

            }
        });
        return map;
    }*

**MODIFIED CODE* *IN PDPageLabels.java


** *public String[] getLabelsByPageIndices()
    {
        final String[] map = new String[doc.getNumberOfPages()];
        computeLabels(new LabelHandler()
        {
            public void newLabel(int pageIndex, String label)
            {
               if(pageIndex < doc.getNumberOfPages()){
                map[pageIndex] = label;
               }
            }
        });
        return map;
    }

*I added a simple IF Loop and it works fine.

*Kindly guide me in this issue

Reply via email to