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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:48:18+00:00 2026-05-22T12:48:18+00:00

My program processes PDF files and reads some streams out of them. There are

  • 0

My program processes PDF files and reads some streams out of them. There are also FlateEncoded streams in there. I use the “inflate()” method of zlib to decompress them.

This usually works really well with the following code:

static string FlateDecode(string s){

    int factor = 50;
    z_stream stream;
    while(true){
        char * out = new char[s.length()*factor];           

        stream.zalloc = Z_NULL;
        stream.zfree = Z_NULL;
        stream.opaque = Z_NULL;
        stream.avail_in = s.length();
        stream.next_in = (Bytef*)s.c_str();
        stream.avail_out = s.length()*factor;
        stream.next_out = (Bytef*)out;
        inflateInit(&stream);
        inflate(&stream, Z_FINISH);
        inflateEnd(&stream);


        if(stream.total_out >= factor*s.length()){
            delete[] out;
            factor *= 2;
            continue;

        }
        string result;
        for(unsigned long i = 0; i < stream.total_out; i++){
            result += out[i];
        }

        delete[] out;
        return result;
    }
}

But inflate has an empty result for some streams. It´s not often, but it happens. Has someone an idea why?

The streams must be ok because all PDF readers read the PDF files correctly.

Thanks for your help!

UPDATE

I’ve uploaded the PDF and the stream so you can check it by your own.

PDF -> The stream starts at byte 43296

Stream

UPDATE 2

I compared the streams that can´t be decompressed with the streams that can be decompressed. I’ve noticed an interesting thing: The working streams all begin with the 2 bytes H%. The problematic streams begin with ö>. Does anyone now what this means?

Thanks for any help!

  • 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-22T12:48:19+00:00Added an answer on May 22, 2026 at 12:48 pm

    zlib simply seems to not support all deflated streams found in PDF files.

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

Sidebar

Related Questions

I'm working on a program that processes many requests, none of them reaching more
Standard streams are associated with a program. So, suppose there is a program already
I'd like to profile a program that forks and spawns several child processes. I
Most program languages have some kind of exception handling; some languages have return codes,
My program generates relatively simple PDF documents on request, but I'm having trouble with
I'm trying to write a basic Erlang program that reads in a file in
I need to pre-produce a million or two PDF files from a simple template
Well I testing my jython program, that does some neat [.xls, .doc, .rtf, .tif,
I'm looking to run multiple concurrent processes in a C program. The programs will
In our C# WinForms application, we generate PDF files and launch Adobe Reader (or

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.