예제 #1
0
        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);
        }
예제 #2
0
        internal CorePDFDirect ReadDirect(int id)
        {
            CorePDFDirect direct1;
            PDFStream     stream1;
            PDFName       name1;
            int           num4;

            if (!this.mXRefValid)
            {
                return(CorePDFNull.Instance);
            }
            if (id > this.mXRef.Count)
            {
                return(CorePDFNull.Instance);
            }
            XRefEntry entry1 = ((XRefEntry)this.mXRef[id]);
            int       num5   = entry1.type;

            switch (num5)
            {
            case 0:
            {
                goto Label_0054;
            }

            case 1:
            {
                if (entry1.offset == ((long)-1))
                {
                    return(CorePDFNull.Instance);
                }
                goto Label_006A;
            }

            case 2:
            {
                stream1 = (this.Indirects[((int)entry1.offset)].Direct as PDFStream);
                if (stream1 == null)
                {
                    return(CorePDFNull.Instance);
                }
                goto Label_00D0;
            }
            }
            goto Label_0218;
Label_0054:
            return(CorePDFNull.Instance);

Label_006A:
            direct1 = null;
            long num1 = this.mParser.Stream.Position;

            direct1 = this.ReadDirectFromStream(this.mParser, entry1.offset, id, entry1.generation);
            this.mParser.Stream.Position = num1;
            return(direct1);

Label_00D0:
            name1 = (stream1.Dict["Type"] as PDFName);
            if (name1 == null)
            {
                throw new PDFException("Invalid Object Stream");
            }
            if (name1.Value != "ObjStm")
            {
                throw new PDFException("Invalid object stream");
            }
            long       num2     = ((long)0);
            PDFInteger integer1 = (stream1.Dict["First"] as PDFInteger);

            if (integer1 == null)
            {
                throw new PDFException("Invalid Object stream");
            }
            long       num3     = integer1.Value;
            PDFInteger integer2 = (stream1.Dict["N"] as PDFInteger);

            if (integer2 == null)
            {
                throw new PDFException("Invalid Object stream");
            }
            bool      flag1   = false;
            Stream    stream2 = stream1.Decode();
            PDFParser parser1 = new PDFParser(stream2, this);

            for (num4 = 0; (num4 < integer2.Int32Value); num4 += 1)
            {
                integer1 = (parser1.ReadNextObject() as PDFInteger);
                if (integer1 == null)
                {
                    throw new PDFException("Invalid object stream");
                }
                if (integer1.Value != ((long)id))
                {
                    parser1.ReadNextObject();
                }
                else
                {
                    integer1 = (parser1.ReadNextObject() as PDFInteger);
                    if (integer1 == null)
                    {
                        throw new PDFException("Invalid object stream");
                    }
                    num2  = (num3 + integer1.Value);
                    flag1 = true;
                    break;
                }
            }
            if (!flag1)
            {
                return(CorePDFNull.Instance);
            }
            stream2.Position = num2;
            return((CorePDFDirect)parser1.ReadNextObject());

Label_0218:
            throw new PDFException("Invalid object type");
        }