Beispiel #1
0
        public Pdf(string filename)
        {
            PdfStream st = new PdfStream();

            st.FillFromFile(filename);

            long pos = st.Position;

            ReadHeader(st);

            // While we're still advancing through the stream, then all is good...
            bool eof = false;

            while (!eof && (st.Position != pos))
            {
                Utility.TraceLine("Starting read pass");
                pos = st.Position;
                ReadComment(st);

                Object obj = ReadObject(st);
                if (obj.Valid)
                {
                    m_objects.Add(obj);

                    if (m_objects.Count == 1)
                    {
                        DictionaryItem di = obj.Dictionary.Get("Linearized");
                        if (di.Valid)
                        {
                            if (di.Type == DictionaryItem.ValueType.Number)
                            {
                                if (di.ValueAsInteger() == 1)
                                {
                                    m_linflag    = true;
                                    m_linearized = true;
                                    Utility.TraceLine("Linearized PDF document found");
                                    Utility.TraceLine("PDF/A: Linearization of document is ignored (section 5.10)");
                                }
                            }
                            else
                            {
                                throw new ParseException("Linearized dictionary item is not a number");
                            }
                        }
                    }
                }

                ReadXref(st);
                if (ReadTrailer(st))
                {
                    if (m_linflag == true)
                    {
                        m_linflag = false;
                        Utility.TraceLine("Linearization trailer");
                    }
                    else
                    {
                        eof = true;
                    }
                }
                ReadStartXref(st);

                if (!eof && (st.Position == pos))
                {
                    st.ReadLine();
                }
            }

            if (st.Position != st.Length)
            {
                m_pdfa = false;
                Utility.TraceLine("PDF/A: Extraneous content after EOF marker breaches section 5.3 requirements");
            }
        }