private void _readXrefTable(PdfStreamReader reader) { PdfValue Token; // Read xref table while ((Token = reader.ReadToken()).Type == PdfValueType.Integer) { int Id = ((PdfInteger)Token).Value; int Count = reader.ReadInt(); _allocateXrefTable(Id + Count); while (Count-- > 0) { int EntryPosition = reader.ReadInt(); int EntryRevision = reader.ReadInt(); bool EntryUsed = (reader.ReadByte() == 'n'); if (EntryPosition >= 10 && EntryUsed) { _xrefTable[Id] = new PdfReferenceReader(this, Id, EntryRevision, EntryPosition); } ++Id; } } // Read trailer if (Token.Type != PdfValueType.Trailer) { throw new PdfExceptionReader("PDF stream corrupt: 'trailer' expected."); } reader.ReadToken(PdfValueType.DictionaryBegin); while ((Token = reader.ReadToken()).Type != PdfValueType.DictionaryEnd) { if (Token.Type == PdfValueType.Name) { switch (((PdfName)Token).Value) { case "Size": if (reader.ReadInt() != _xrefTable.Length) { throw new PdfExceptionReader("PDF stream corrupt: Xref table size d'not match trailer 'Size'."); } break; case "Prev": { var p = reader.ReadInt(); reader.ReadToken(PdfValueType.Xref); _readXrefTable(new PdfStreamReader(this, _stream, p)); } break; case "Root": _rootReference = pdfGetReference(reader.ReadReference()); break; case "Encrypt": _encryptReference = pdfGetReference(reader.ReadReference()); break; case "Info": _infoReference = pdfGetReference(reader.ReadReference()); break; case "ID": { List <PdfValue> ID = new List <PdfValue>(); reader.ReadToken(PdfValueType.ArrayBegin); while ((Token = reader.ReadToken()).Type != PdfValueType.ArrayEnd) { ID.Add(Token); } _id = ID.ToArray(); } break; } } } }