private ObjectCollection TraversePagesTree(Object top) { ObjectCollection retval = new ObjectCollection(); if (top.Type == "Page") { Utility.TraceLine("Found a page: " + top.ToString()); retval.Add(top); return(retval); } if (top.Type == "Pages") { DictionaryItem kids = top.Dictionary.Get("Kids"); foreach (Object kid in kids.ValueAsObjects(m_objects)) { retval.Add(TraversePagesTree(kid)); } return(retval); } if (top.Type == "") { foreach (Object kid in top.DirectValueAsObjects(m_objects)) { retval.Add(TraversePagesTree(kid)); } return(retval); } throw new RuntimeException("Unknown object type \"" + top.Type + "\" in object " + top.Number + " " + top.Generation + " pages tree"); }
public ObjectCollection ByType(string type) { ObjectCollection oc = new ObjectCollection(); foreach (Object o in List) { if ((o.Valid) && (o.Type == type)) { oc.Add(o); } } return(oc); }
public ObjectCollection ValueAsObjects(ObjectCollection objs) { if (!Valid) { return(new ObjectCollection()); } if (m_objects.Count == 0) { throw new RuntimeException("There are no objects to return"); } ObjectCollection oc = new ObjectCollection(); foreach (ObjectReference or in m_objects) { oc.Add(objs.Get(or)); } return(oc); }
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"); } }