Beispiel #1
0
        internal XStringFormat GetAlignment(DictionaryElements dict)
        {
            PdfItem item = dict.GetValue("/Q");

            if (item != null)
            {
                int alignment = Int32.Parse(item.ToString());

                switch (alignment)
                {
                case 0:
                    return(XStringFormats.TopLeft);

                case 1:
                    return(XStringFormats.TopCenter);

                case 2:
                    return(XStringFormats.TopRight);

                default:
                    return(XStringFormats.TopLeft);
                }
            }
            else
            {
                return(XStringFormats.TopLeft);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Returns all PdfDictionaries saved in the "/K" key.
        /// </summary>
        internal static IEnumerable <PdfDictionary> GetKids(DictionaryElements elements)
        {
            if (elements != null)
            {
                var k = elements.GetObject(Keys.K);

                var array = k as PdfArray;
                // If k is holding an array, return all elements.
                if (array != null)
                {
                    foreach (var item in array)
                    {
                        var dict = GetPdfDictionary(item);
                        if (dict != null)
                        {
                            yield return(dict);
                        }
                    }
                }
                else
                {
                    var dict = GetPdfDictionary(k);
                    if (dict != null)
                    {
                        yield return(dict);
                    }
                }
            }
        }
Beispiel #3
0
        //public static string Key = "/PdfSharp.CustomValue";

        internal static PdfCustomValues Get(DictionaryElements elem)
        {
            string          key = elem.Owner.Owner.Internals.CustomValueKey;
            PdfCustomValues customValues;
            PdfDictionary   dict = elem.GetDictionary(key);

            if (dict == null)
            {
                customValues = new PdfCustomValues();
                elem.Owner.Owner.Internals.AddObject(customValues);
                elem.Add(key, customValues);
            }
            else
            {
                customValues = dict as PdfCustomValues;
                if (customValues == null)
                {
                    customValues = new PdfCustomValues(dict);
                }
            }
            return(customValues);
        }
Beispiel #4
0
 internal static void Remove(DictionaryElements elem)
 {
     elem.Remove(elem.Owner.Owner.Internals.CustomValueKey);
 }