Exemplo n.º 1
0
 protected PdfPage(PdfIndirectReference pages, PdfPageTree parent, PdfObjectType type)
     : base(type)
 {
     GenerationNumber = pages.GenerationNumber;
     ObjectNumber     = pages.ObjectNumber;
     Parent           = parent;
 }
Exemplo n.º 2
0
        public PdfPage(PdfIndirectReference pages, PdfPageTree parent)
            : this(pages, parent, PdfObjectType.Page)
        {
            IsContainer = true;

            var page = pages.Dereference <PdfDictionary>();

            page.ExpectsType("Page");

            foreach (PdfKeyValuePair pair in page.Items)
            {
                HandleKeyValuePair(pair);
            }
        }
Exemplo n.º 3
0
        public PdfPageTree(PdfIndirectReference pages, PdfPageTree parent)
            : base(pages, parent, PdfObjectType.PageTree)
        {
            IsContainer = true;
            var pageTree = pages.Dereference <PdfDictionary>();

            pageTree.ExpectsType("Pages");

            foreach (PdfKeyValuePair pair in pageTree.Items)
            {
                switch (pair.Key.Text)
                {
                case "Type":     // skip Type Pages
                    break;

                case "Kids":
                    var kids = (PdfArray)pair.Value;
                    Kids = new List <IPdfObject>();
                    foreach (PdfIndirectReference item in kids.Items)
                    {
                        var    dic  = item.Dereference <PdfDictionary>();
                        string type = dic["Type"].Text;
                        if (type == "Pages")
                        {
                            Kids.Add(new PdfPageTree(item, this));
                        }
                        else if (type == "Page")
                        {
                            Kids.Add(new PdfPage(item, this));
                        }
                        else
                        {
                            throw new Exception("Content of Kids in a Page Tree Node must be either a Page or another Page Tree Node");
                        }
                    }
                    break;

                case "Count":
                    Count = new PdfCount(pair.Value as PdfNumeric);
                    _items.Add(Count);
                    break;

                default:
                    HandleKeyValuePair(pair);
                    break;
                }
            }
            _items.AddRange(Kids);
        }
Exemplo n.º 4
0
        public PdfPageTree(PdfIndirectReference pages, PdfPageTree parent)
            : base(pages, parent, PdfObjectType.PageTree)
        {
            IsContainer = true;
            var pagetree = pages.Dereference<PdfDictionary>();
            pagetree.ExpectsType("Pages");

            foreach (PdfKeyValuePair pair in pagetree.Items)
            {
                switch (pair.Key.Text)
                {
                case "Type": // skip Type Pages
                    break;
                case "Kids":
                    PdfArray kids = pair.Value as PdfArray;
                    Kids = new List<IPdfObject>();
                    foreach (PdfIndirectReference item in kids.Items)
                    {
                        var dic = item.Dereference<PdfDictionary>();
                        String type = dic["Type"].Text;
                        if (type == "Pages")
                            Kids.Add(new PdfPageTree(item, this));
                        else if (type == "Page")
                            Kids.Add(new PdfPage(item, this));
                        else
                            throw new Exception("Content of Kids in a Page Tree Node must be either a Page or another Page Tree Node");
                    }
                    break;
                case "Count":
                    Count = new PdfCount(pair.Value as PdfNumeric);
                    _items.Add(Count);
                    break;
                default:
                    HandleKeyValuePair(pair);
                    break;
                }
            }
            _items.AddRange(Kids);
        }
Exemplo n.º 5
0
        public PdfCatalog(PdfDictionary catalog)
            : base(PdfObjectType.Catalog)
        {
            IsContainer = true;
            catalog.ExpectsType("Catalog");

            foreach (PdfKeyValuePair pair in catalog.Items)
            {
                switch (pair.Key.Text)
                {
                case "Type":     // skip Type Catalog
                    break;

                case "Pages":
                    Pages = new PdfPageTree(catalog["Pages"] as PdfIndirectReference);
                    break;

                default:
                    _items.Add(pair);
                    break;
                }
            }
        }