예제 #1
0
        /**
         * In case an object is an array, a dictionary or a stream,
         * we need to loop over the entries and process them one by one.
         * @param object    the object to examine
         */
        protected void LoopOver(PdfObject @object)
        {
            switch (@object.Type)
            {
            case PdfObject.ARRAY:
                PdfArray array = (PdfArray)@object;
                for (int i = 0; i < array.Size; i++)
                {
                    Process(array.GetDirectObject(i));
                }
                break;

            case PdfObject.DICTIONARY:
            case PdfObject.STREAM:
                PdfDictionary dict = (PdfDictionary)@object;
                if (dict.IsPages())
                {
                    break;
                }
                foreach (PdfName name in dict.Keys)
                {
                    Process(dict.GetDirectObject(name));
                }
                break;
            }
        }
        private void AddPagesFromDict(PdfObject dictRef, IList <PdfDictionary> pages, IList <RefKey> pagesRef)
        {
            PdfDictionary dict = (PdfDictionary)PdfReader.GetPdfObject(dictRef);

            if (dict.IsPages())
            {
                PdfArray kids = dict.GetAsArray(PdfName.KIDS);
                if (kids == null)
                {
                    return;
                }
                foreach (PdfObject kid in kids)
                {
                    AddPagesFromDict(kid, pages, pagesRef);
                }
            }
            else if (dict.IsPage())
            {
                pages.Add(dict);
                pagesRef.Add(new RefKey((PRIndirectReference)dictRef));
            }
        }