Example #1
0
        private PDFObjectRef[] GetAllPages(PDFObjectRef pageTreeRef, PDFFile origFile)
        {
            IFileObject fo = origFile.GetContent(pageTreeRef);

            if (null == fo || !(fo is PDFDictionary))
            {
                return new PDFObjectRef[] { }
            }
            ;

            PDFDictionary dict = fo as PDFDictionary;

            if (null == dict)
            {
                return new PDFObjectRef[] { }
            }
            ;

            PDFName type = dict["Type"] as PDFName;

            if (null == type || type.Value != "Pages")
            {
                return new PDFObjectRef[] { }
            }
            ;


            PDFArray kids = dict["Kids"] as PDFArray;

            if (null == kids || kids.Count == 0)
            {
                return new PDFObjectRef[] { }
            }
            ;

            List <PDFObjectRef> allPages = new List <PDFObjectRef>();

            foreach (IFileObject item in kids)
            {
                PDFObjectRef pageRef = item as PDFObjectRef;

                if (null != pageRef)
                {
                    allPages.Add(pageRef);
                }
            }
            return(allPages.ToArray());
        }