Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 451571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:58:55+00:00 2026-05-12T21:58:55+00:00

Hello i have trouble with parsing a pdf when the iterator reaches page 11

  • 0

Hello i have trouble with parsing a pdf when the iterator reaches page 11 an exception is throw.

Any ideas? Thanks

Here’s my code:

import java.io.*;
import java.nio.charset.Charset;
import java.util.regex.*;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.hyphenation.TernaryTree.Iterator;
import com.lowagie.text.pdf.parser.PdfTextExtractor;

public class PdfParser {
    /** 
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int index = 0;
        try {
            PdfReader readerN = new PdfReader("C:\\Documents and Settings\\stefan.stere\\hibernateWorkspace\\PdfParser\\src\\monitor3.pdf");
            OutputStreamWriter out = new OutputStreamWriter( new FileOutputStream(new File("C:\\Documents and Settings\\stefan.stere\\hibernateWorkspace\\PdfParser\\src\\pdf2txt.rtf")),"Cp1252");

            PdfTextExtractor parse = new PdfTextExtractor(readerN);
            int nrPages = readerN.getNumberOfPages();

            for (int i=1; i<nrPages ; i++) {
                index++;
                String page = parse.getTextFromPage(i);
                if(page != null){
                    page = page.replace(new StringBuffer("null"), new StringBuffer("??"));
                    page = page.replaceAll("Comercial.", "Comerciala");
                    page = page.replaceAll("ACT ADI..IONAL", "ACT ADITIONAL");
                    page = page.replaceAll("HOT.R..E", "HOTARARE");
                    page = page.replaceAll("HOT.R..EA", "HOTARAREA");
                    page = page.replaceAll("HOT.R..I", "HOTARARI");
                    page = page.replaceAll("..cheiat.", "incheiata");
                    page = page.replaceAll("ANUN..", "ANUNT");
                    out.write(page);
                    System.out.println(page);
                }
            }
            out.close();
            readerN.close();
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
            System.out.println(index);
        }
    }
}

and the exception stack:

java.lang.ArrayIndexOutOfBoundsException: Invalid index: 62
at com.lowagie.text.pdf.CMapAwareDocumentFont.decodeSingleCID(Unknown Source)
at com.lowagie.text.pdf.CMapAwareDocumentFont.decode(Unknown Source)
at com.lowagie.text.pdf.parser.PdfContentStreamProcessor.decode(Unknown Source)
at com.lowagie.text.pdf.parser.PdfContentStreamProcessor.displayPdfString(Unknown Source)
at com.lowagie.text.pdf.parser.PdfContentStreamProcessor$ShowTextArray.invoke(Unknown Source)
at com.lowagie.text.pdf.parser.PdfContentStreamProcessor.invokeOperator(Unknown Source)
at com.lowagie.text.pdf.parser.PdfContentStreamProcessor.processContent(Unknown Source)
at com.lowagie.text.pdf.parser.PdfTextExtractor.getTextFromPage(Unknown Source)
at PdfParser.main(PdfParser.java:32)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T21:58:56+00:00Added an answer on May 12, 2026 at 9:58 pm

    No answer but it seems a lot of people have the same problem, there’s another related question on SO. And if you search with ArrayIndexOutOfBoundsException and getTextFromPage on google you see the same problem but no solution…

    BTW, your loop will stop before processing the last page as the first page has index 1…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have a trouble customizing a background of the grouped table view.. Here's
Hello I have been having trouble with this for a while now. I have
Hello I have the following code namespace ConsoleApplication2 { class Program { static void
Hello i have this form filling javascript: function onLine(code,nn) { document.writeform.bericht.value+=code; document.writeform.bericht.focus(); document.writeform.nickname.value+=nn; write1();
Hello guys I have a little trouble with the my method [HTTPost], please see
Hello I'm having trouble figuring this out. I have these structs and classes. struct
I'm having some trouble figuring this out. I have the following CSV string hello
I have this code : $str=preg_replace( '#\b[^](Hello User)#', '<a href=$1>$1</a>', $str); return nl2br($str); So,
I'm having trouble compiling D programs in Code::Blocks. Here's what I'm doing: In accordance
I have trouble understanding the underlying errors with the code below: class myClass {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.