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 9195233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:35:06+00:00 2026-06-17T21:35:06+00:00

I am trying to extract image metadata (and the image) for images embedded in

  • 0

I am trying to extract image metadata (and the image) for images embedded in pdfs, using pdfbox. I have the following problem,

for each page i:
 for each image j in page i:
  extract metadata, output
  create the image file in separate thread

Now, I have the following code for creating the image file, which is included in a method called generate_image() in FileWritingclass implementing Runnable. This method is called from run(). The code follows:

try {
    File F=new File(figurename);
    item.getImage().write2file( F );


} catch (Exception e) {
    e.printStackTrace();
} 

where item.getImage() returns a PDXObjectImage object. If I do this without creating a separate thread, it works fine, but when I create a thread to do this task, it shows following error:

java.lang.IndexOutOfBoundsException: Index: 5, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:604)
at java.util.ArrayList.get(ArrayList.java:382)
at org.apache.pdfbox.io.RandomAccessBuffer.seek(RandomAccessBuffer.java:84)
at org.apache.pdfbox.io.RandomAccessFileInputStream.read(RandomAccessFileInputStream.java:96)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
at java.io.FilterInputStream.read(FilterInputStream.java:107)
at org.apache.pdfbox.pdmodel.graphics.xobject.PDCcitt$TiffWrapper.read(PDCcitt.java:468)
at org.apache.pdfbox.io.IOUtils.copy(IOUtils.java:68)
at org.apache.pdfbox.pdmodel.graphics.xobject.PDCcitt.write2OutputStream(PDCcitt.java:184)
at org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage.write2file(PDXObjectImage.java:165)
at extractor.FileWriting.generate_image(FileWriting.java:136)

Can anyone please point out where I am going wrong?

  • 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-06-17T21:35:07+00:00Added an answer on June 17, 2026 at 9:35 pm

    I suspect that your problem is that you are using the same pdfbox classes in multiple threads.

    Older versions of PDFBox had this in their FAQ page:

    Is PDFBox thread safe?

    No! Only one thread may access a single document at a time. You can have multiple threads each accessing their own PDDocument object.

    However, in 2.0+ (maybe?) the PDFBox FAQ page now says:

    PDFBox has experimental support for read-only operations on the same PDDocument from different threads.

    Given the discussion right now (June 2019), this doesn’t seem promising however. So, unless you want to live on the edge, you still should consider using a ThreadLocal and keeping one PDDocument or whatever class you are using. Something like:

    private ThreadLocal<PDDocument> localPdDocument = new ThreadLocal<PDDocument>() {
        @Override
        protected PDDocument initialValue() {
            return new PDDocument();
        }
    };
    
    ...
    PDDocument doc = localPdDocument.get();
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to extract the images from the given web page. I have
I'm trying to extract metadata from a PNG image format. I'm using this library?
I'm trying to extract EXIF information from images using jQuery. I've tried using a
I am trying to extract images from flash on the following web-site: http://meijer.shoplocal.com/meijer/default.aspx?action=entryflash&storeref=120 I
I am trying to extract an image from a HTTP stream. I have a
I am trying to extract all the images from a pdf using itextsharp but
I have an image, and I'm trying to extract a certain channel depending on
I am trying to extract specific content(links, text, images) from an HTML page. Is
I have limited experience with JSON, and am trying to extract image URLs from
I'm trying to extract src value from image tag using prag_match with perl pattern.

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.