Beispiel #1
0
        private void readPages(PDFArray kids, PDFArray newKids, IPDFObject resources, IPDFObject mediaBox, IPDFObject cropBox, IPDFObject rotate)
        {
            if (kids != null)
            {
                for (int i = 0; i < kids.Count; ++i)
                {
                    PDFDictionary dict = kids[i] as PDFDictionary;
                    if (dict != null)
                    {
                        PDFName type = dict["Type"] as PDFName;
                        if (type != null)
                        {
                            if (type.GetValue() == "Pages")
                            {
                                IPDFObject tmp = dict["Resources"];
                                if (tmp != null)
                                {
                                    resources = tmp;
                                }

                                tmp = dict["MediaBox"];
                                if (tmp != null)
                                {
                                    mediaBox = tmp;
                                }

                                tmp = dict["CropBox"];
                                if (tmp != null)
                                {
                                    cropBox = tmp;
                                }

                                tmp = dict["Rotate"];
                                if (tmp != null)
                                {
                                    rotate = tmp;
                                }

                                readPages(dict["Kids"] as PDFArray, newKids, resources, mediaBox, cropBox, rotate);
                            }
                            else if (type.GetValue() == "Page")
                            {
                                newKids.AddItem(dict);
                                dict.AddItem("Parent", GetDictionary());
                                dict.AddItemIfNotHave("Resources", resources);
                                dict.AddItemIfNotHave("MediaBox", mediaBox);
                                dict.AddItemIfNotHave("CropBox", cropBox);
                                dict.AddItemIfNotHave("Rotate", rotate);

                                Page page = new Page(dict, _owner);
                                _pages.Add(page);
                            }
                        }
                    }
                }
            }
        }