Why do I get an exception when processing some PDF documents?

Q: We're currently using 5.5. For testing I use a somewhat large
corpus of PDF files randomly grab from the internet, feeding them
into PDFDoc and collecting statistics, like a number of fields,
annotations, and properties.

On some files I get exception such as:

Message: Compressed object is corrupt
Conditional expression: GetObj()

I'm guessing it something I'm doing but I can't figure out where I'm
going wrong. I'm using the 32-bit .NET 4.0 version of the 5.5 DLL,
building on Visual Studio 2010 in Windows 7 (32-bit). Most PDFs are

This code snippet brings about the exceptions I'm seeing:

using (var inputStream = new FileStream(file, FileMode.Open)) {
    PDFDoc doc = new PDFDoc(inputStream);

    PDFDocInfo info = doc.GetDocInfo();
    if (info != null)
        // 0.pdf and 11.pdf throw exception here
        if (!string.IsNullOrEmpty(info.GetAuthor()))

    // Some PDFs are throwing on doc.GetFieldIterator
    for (FieldIterator iterator = doc.GetFieldIterator();
iterator.HasNext(); iterator.Next())

    // Some throw on doc.GetPageIterator
    for (PageIterator iterator = doc.GetPageIterator();
iterator.HasNext(); iterator.Next())
        Page page = iterator.Current();
        int annotations = page.GetNumAnnots();
        for (int i = 0; i < annotations; i++)
            Annot annotation = page.GetAnnot(i);

Let me know if you need any more information on my side.

A: The problem is that some PDF files are encrypted. To resolve the
problem simply call 'doc.InitSecurityHandler()' after each 'PDFDoc'
constructor. This is generally a good idea since there is no side
effect from calling this method.

As an aside, unless you are planning to load file from memory it is
more efficient to open the file direct using filename (e.g.
PDFDoc(path)) than using FileStream. Also the file should be disposed
when it is no longer in use. For example:

using (PDFDoc doc = new PDFDoc(@"c:\my.pdf")) {
   // ...

As a starting point you may want to start from one of the provided
samples (http://www.pdftron.com/pdfnet/samplecode.html).