nattsurf123 0 Newbie Poster

I'm trying to decode a flatencoded pdf stream. I get the exception:
Index was outside the bounds of the array.
I don't understand because I have tried to be really exact.
I Would appreciate your help on this.

Here is the code I'm using.

 ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
        byte[] buffer=encoding.GetBytes(data);
    byte[] decomp = Decompress(buffer);

    public static byte[] Decompress(byte[] data)
    {

        MemoryStream input = new MemoryStream();
        input.Write(data, 0, data.Length);
        input.Position = 0;


        DeflateStream gzip = new DeflateStream(input, CompressionMode.Decompress, false);

        input.ReadByte();
        input.ReadByte();

        MemoryStream output = new MemoryStream();
        byte[] buff = new byte[64];
        int read = -1;
        read = gzip.Read(buff, 0, buff.Length);

        while (read > 0)
        {
            output.Write(buff, 0, read);
            read = gzip.Read(buff, 0, buff.Length);
        }
        gzip.Close();
        return output.ToArray();
    }

If you can't find anything without testing then I can upload the stream file I'm working on.
I managed to decode it with a PHP application so it seams right.

Thanks for you help.