internal CorePDFDirect ReadDirectFromStream(PDFParser p, long offset, int id, int gene) { PDFInteger integer1; PDFInteger integer2; PDFName name1; CorePDFDirect direct1; long num1; CorePDFDirect direct2; p.Stream.Position = offset; try { integer1 = ((PDFInteger)p.ReadNextObject()); if ((integer1.Value != ((long)id)) && (id != -1)) { throw new PDFSyntaxException("XREF points to incorrect object. objId doesn\'t match"); } integer2 = ((PDFInteger)p.ReadNextObject()); if ((integer2.Value != ((long)gene)) && (gene != -1)) { throw new PDFSyntaxException("XREF points to incorrect object. Generation number doesn\'t match"); } name1 = ((PDFName)p.ReadNextObject()); if (name1.Value != "obj") { throw new PDFSyntaxException("XREF points to incorrect object. \'obj\' token missing"); } direct1 = ((CorePDFDirect)p.ReadNextObject()); name1 = ((PDFName)p.ReadNextObject()); if (name1.Value == "stream") { p.SkipToEOL(); num1 = p.Stream.Position; direct1 = new CorePDFStream(this, p.Stream, num1, ((CorePDFDict)direct1)); name1 = ((PDFName)p.ReadNextObject()); if (name1.Value != "endstream") { throw new PDFSyntaxException("XREF points to incorrect object. \'endstream\' token missing"); } name1 = ((PDFName)p.ReadNextObject()); } if (base.IsEncrypted) { this.DecryptObject(direct1, id, gene); } if (name1.Value == "endobj") { return(direct1); } throw new PDFSyntaxException("XREF points to incorrect object. \'endobj\' or \'stream\' token missing"); } catch (InvalidCastException) { throw new PDFSyntaxException("XREF points to incorrect object"); } return(direct2); }