InheritValues() статический приватный Метод

Inherit values from parent node.
static private InheritValues ( PdfSharp.Pdf.PdfDictionary page, InheritedValues values ) : void
page PdfSharp.Pdf.PdfDictionary
values InheritedValues
Результат void
Пример #1
0
        /// <summary>
        /// Recursively converts the page tree into a flat array.
        /// </summary>
        PdfDictionary[] GetKids(PdfReference iref, PdfPage.InheritedValues values, PdfDictionary parent)
        {
            // TODO: inherit inheritable keys...
            PdfDictionary kid = (PdfDictionary)iref.Value;

            if (kid.Elements.GetName(Keys.Type) == "/Page")
            {
                PdfPage.InheritValues(kid, values);
                return(new PdfDictionary[] { kid });
            }
            else
            {
                Debug.Assert(kid.Elements.GetName(Keys.Type) == "/Pages");
                PdfPage.InheritValues(kid, ref values);
                List <PdfDictionary> list = new List <PdfDictionary>();
                PdfArray             kids = kid.Elements["/Kids"] as PdfArray;
                //newTHHO 15.10.2007 begin
                if (kids == null)
                {
                    PdfReference xref3 = kid.Elements["/Kids"] as PdfReference;
                    kids = xref3.Value as PdfArray;
                }
                //newTHHO 15.10.2007 end
                foreach (PdfReference xref2 in kids)
                {
                    list.AddRange(GetKids(xref2, values, kid));
                }
                int count = list.Count;
                Debug.Assert(count == kid.Elements.GetInteger("/Count"));
                //return (PdfDictionary[])list.ToArray(typeof(PdfDictionary));
                return(list.ToArray());
            }
        }
Пример #2
0
        /// <summary>
        /// Replaces the page tree by a flat array of indirect references to the pages objects.
        /// </summary>
        internal void FlattenPageTree()
        {
            // Acrobat creates a balanced tree if the number of pages is rougly more than ten. This is
            // not difficult but obviously also not necessary. I created a document with 50000 pages with
            // PDF4NET and Acrobat opened it in less than 2 seconds.

            //PdfReference xrefRoot = this.Document.Catalog.Elements[PdfCatalog.Keys.Pages] as PdfReference;
            //PdfDictionary[] pages = GetKids(xrefRoot, null);

            // Promote inheritable values down the page tree
            PdfPage.InheritedValues values = new PdfPage.InheritedValues();
            PdfPage.InheritValues(this, ref values);
            PdfDictionary[] pages = GetKids(Reference, values, null);

            // Replace /Pages in catalog by this object
            // xrefRoot.Value = this;

            PdfArray array = new PdfArray(Owner);

            foreach (PdfDictionary page in pages)
            {
                // Fix the parent
                page.Elements[PdfPage.Keys.Parent] = Reference;
                array.Elements.Add(page.Reference);
            }

            Elements.SetName(Keys.Type, "/Pages");
#if true
            // direct array
            Elements.SetValue(Keys.Kids, array);
#else
            // incdirect array
            this.Document.xrefTable.Add(array);
            Elements.SetValue(Keys.Kids, array.XRef);
#endif
            Elements.SetInteger(Keys.Count, array.Elements.Count);
        }