public bool ReadXref(PdfStream st) { if (st.PeekLine(true, true) == "xref") { Utility.TraceLine("Reading a XREF"); st.ReadLine(); while (st.RegexMatch("^([0-9]+ [0-9]+)", false) != "") { Utility.TraceLine("Found XREF value block"); // Each xref block starts with a line with the starting number of the objects in the // block, and then a count of the number of objects in the block PDF 1.5 p70 int startat = 0; int count = 0; try { startat = Int32.Parse(st.RegexMatch("^([0-9]+)", true)); count = Int32.Parse(st.RegexMatch("^[ \t]*([0-9]+)", true)); st.ReadLine(); // The you get one line per object in the block. They contain: // <byte offset> <generation> <n = inuse, f = free> Utility.TraceLine("XREF reading " + count + " lines"); for (int i = 0; i < count; i++) { string line = st.ReadLine(); long offset = Int64.Parse(line.Substring(0, 10)); int generation = Int32.Parse(line.Substring(11, 5)); string inuse = line.Substring(17, 1); Utility.TraceLine("XREF line: " + offset + " " + generation + " " + inuse); if ((inuse == "n") && !m_linflag) { // PDF/A requires us to verify these offsets Object obj = m_objects.Get(startat + i, generation); if (offset != obj.StartedAt) { m_pdfa = false; Utility.TraceLine("PDF/A: Object offset is incorrect " + offset + " != " + obj.StartedAt + " (required by section 5.4)"); } } } } catch (Exception except) { throw new ParseException("Error reading xref block starter: " + except.Message); } } } return(false); }
public Object ValueAsObject(ObjectCollection objs) { if (!Valid) { return(new Object()); } if (m_objects.Count == 0) { return(new Object()); } if (m_objects.Count != 1) { return(new Object()); } return(objs.Get(m_objects[0])); }
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); }