// not used /* #region private PDFObjectRef[] InitPageRefs() * * private PDFObjectRef[] InitPageRefs() * { * List<PDFObjectRef> all = new List<PDFObjectRef>(); * PDFObjectRef pagetree = this.DocumentCatalog[PagesName] as PDFObjectRef; * if (null != pagetree) * this.InitAPageOrTree(pagetree, all, null); * * return all.ToArray(); * } * #endregion * #region private void InitAPageOrTree(PDFObjectRef pagetree, List<PDFObjectRef> all) * * private void InitAPageOrTree(PDFObjectRef pageref, List<PDFObjectRef> all, PDFDictionary inherited) * { * IParsedIndirectObject obj = this._reader.GetObject(pageref); * if (null == obj) * throw new PDFNativeParserException("Cannot find object with reference '" + pageref.ToString()); * * PDFDictionary dict = obj.GetContents() as PDFDictionary; * if (null == dict) * return; * * PDFName type = dict[TypeName] as PDFName; * if (null == type) * { * return; * } * else if (type.Value == "Pages") * { * PDFDictionary newinherited = null; * PDFArray kids = null; * //Type, Parent, Kids, Count are standard * //Others are then inherited in the page. * foreach (KeyValuePair<PDFName, IFileObject> item in dict) * { * switch (item.Key.Value) * { * case ("Type"): * case ("Parent"): * case ("Count"): * //Do nothing * break; * case ("Kids"): * kids = item.Value as PDFArray; * break; * default: * if (null == newinherited) * newinherited = new PDFDictionary(); * * newinherited.Add(item.Key, item.Value); * break; * } * * } * if (null != newinherited && newinherited.Count > 0) * { * if (null != inherited && inherited.Count > 0) * { * foreach (KeyValuePair<PDFName, IFileObject> item in inherited) * { * newinherited.Add(item.Key, item.Value); * } * } * } * else * newinherited = inherited; * * if (null != kids) * { * foreach (PDFObjectRef oref in kids) * { * InitAPageOrTree(oref, all, newinherited); * } * } * } * else if (type.Value == "Page") * { * all.Add(pageref); * * } * * } * #endregion */ // // public interface // #region public IFileObject GetContent(PDFObjectRef oref) /// <summary> /// Gets the main content of object based on the reference /// </summary> /// <param name="oref"></param> /// <returns></returns> public IFileObject GetContent(PDFObjectRef oref) { IParsedIndirectObject obj = this._reader.GetObject(oref); if (null == obj) { return(null); } else { return(obj.GetContents()); } }
/// <summary> /// Returns true if the object in the file (with reference oref) has an associated stream, /// and if so sets the data value to that stream data /// </summary> /// <param name="oref"></param> /// <param name="data"></param> /// <returns></returns> public bool TryGetStreamData(PDFObjectRef oref, out byte[] data) { data = null; IParsedIndirectObject obj = this._reader.GetObject(oref); if (null == obj) { return(false); } else { data = obj.GetStreamData(); return(null != data); } }