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

  • Home
  • SEARCH
  • 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 8071803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:48:52+00:00 2026-06-05T13:48:52+00:00

I am getting a zip file as an InputStream . I am then separating

  • 0

I am getting a zip file as an InputStream. I am then separating each file inside it. Then I am passing the same byte array to a pdfbox which internally uses Apace pdf box 1.6.0 to convert it to image.

However when I pass the byte array to the PDFDocumentReader I get the following exception-

SEVERE: expected='endstream' actual='' org.apache.pdfbox.io.PushBackInputStream@44c2beb9
java.io.IOException: expected='endstream' actual='' org.apache.pdfbox.io.PushBackInputStream@44c2beb9
at org.apache.pdfbox.pdfparser.BaseParser.parseCOSStream(BaseParser.java:439)
at org.apache.pdfbox.pdfparser.PDFParser.parseObject(PDFParser.java:530)
at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:172)
at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:862)
at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:829)
at org.dopdf.document.read.pdf.PDFDocumentReader.init(PDFDocumentReader.java:98)

To fetch each file from the zip I use the following code –

    ZipInputStream zis = new ZipInputStream(aZipFile); // aZipFile is byte array
    ZipEntry entry;
    ArrayList<String> nameOfIgnoredFiles = new ArrayList<String>();
    byte data[] = null;
    while ((entry = zis.getNextEntry()) != null) {
        if (entry.getName().endsWith(".pdf")) {
            int dataSize = (int)entry.getSize();
            data = new byte[dataSize];
            zis.read(data);
            // i use data and pass it to the pdf box.
        } else {
            nameOfIgnoredFiles.add(entry.getName());
        }

The data byte array that I fetch above is then passed to like below –

PDFDocumentReader document = new PDFDocumentReader(data); // here i get the error

What am I doing wrong? Can you suggest a solution? I guess the fetching of the data byte array is an issue. How to do it the best way?

  • 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-05T13:48:53+00:00Added an answer on June 5, 2026 at 1:48 pm

    You are assuming that zis.read(data) fills the buffer. Check the API documentation. It isn’t guaranteed to do that. You are also assuming that the size fits into an int, and that the item itself fits into memory. None of these assumptions is valid.

    Surely you can pass the entry’s InputStream to a pdfbox API?

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

Sidebar

Related Questions

I'm getting the following error when trying to deploy a ZIP file to a
I am working on an API which returns me a zip file containing multiple
I'm trying to create a zip file from a directory in Java, then place
I am downloading a zip file using the zend httpClient, and getting the contents
I searched for unzipping the .zip file which is downloaded in the document directory.
I'm getting IndexOutOfBoundsException while uploading a zip file. What could be the reason? How
I have a zip file containing a folder and inside the folder I have
I am getting an error about the assembly C:\Ora10g\bin\Zip.exe. The trouble is this solution
I am having some trouble getting expected results out of the zip command. Cases
My Java application is currently using ZIP as a project file format. The project

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.