Exemple #1
0
        private long findXref()
        {
            long startxref = _lexer.FindLastSubstring("startxref");

            if (startxref < 0)
            {
                throw new InvalidDocumentException();
            }

            _lexer.Position = startxref + 9;
            bool succes;

            startxref = _lexer.ReadInteger(out succes);
            if (!succes || startxref < 0)
            {
                return(0);
            }
            return(startxref);
        }
Exemple #2
0
        private void parseGenerationEntry(Entry entry)
        {
            PDFDictionaryStream dictStream = GetObject(entry.Offset) as PDFDictionaryStream;

            if (dictStream != null)
            {
                PDFNumber n = dictStream.Dictionary["N"] as PDFNumber;
                if (n == null)
                {
                    return;
                }
                int count = (int)n.GetValue();
                if (count <= 0)
                {
                    return;
                }

                n = dictStream.Dictionary["First"] as PDFNumber;
                if (n == null)
                {
                    return;
                }
                int first = (int)n.GetValue();
                if (first < 0)
                {
                    return;
                }

                dictStream.Decode();
                List <int> objects = new List <int>();
                List <int> offsets = new List <int>();

                Lexer lexer = new Lexer(dictStream.GetStream(), this, null, 512);
                lexer.Position = 0;

                for (int i = 0; i < count; ++i)
                {
                    bool succes;
                    int  objNo = lexer.ReadInteger(out succes);
                    if (!succes)
                    {
                        break;
                    }
                    int offset = lexer.ReadInteger(out succes);
                    if (!succes)
                    {
                        break;
                    }
                    objects.Add(objNo);
                    offsets.Add(offset);
                }

                int l = objects.Count;
                for (int i = 0; i < l; ++i)
                {
                    lexer.Position = offsets[i] + first;
                    IPDFObject obj = lexer.ReadObject();
                    if (obj == null)
                    {
                        obj = new PDFNull();
                    }

                    int index = objects[i];
                    if (index >= 0 && index < _entries.Count)
                    {
                        if (_entries[index] == null)
                        {
                            _entries[index] = new Entry(0, 0);
                        }
                        if (entry.Offset == _entries[index].Offset)
                        {
                            _entries[index].Object = obj;
                        }
                    }
                }
            }
        }