示例#1
0
 internal static Hashtable ReadFontProperties(String name)
 {
     try {
         name += ".properties";
         Stream          isp = GetResourceStream(RESOURCE_PATH + name);
         itextProperties p   = new itextProperties();
         p.Load(isp);
         isp.Close();
         IntHashtable W = CreateMetric(p["W"]);
         p.Remove("W");
         IntHashtable W2 = CreateMetric(p["W2"]);
         p.Remove("W2");
         Hashtable map = new Hashtable();
         foreach (string key in p.Keys)
         {
             map[key] = p[key];
         }
         map["W"]  = W;
         map["W2"] = W2;
         return(map);
     }
     catch {
         // empty on purpose
     }
     return(null);
 }
示例#2
0
        public static void Register(itextProperties attributes)
        {
            string path;
            string alias = null;

            path  = attributes.Remove("path");
            alias = attributes.Remove("alias");

            fontImp.Register(path, alias);
        }
示例#3
0
        public virtual void Register(itextProperties attributes)
        {
            string path;
            string alias = null;

            path  = attributes.Remove("path");
            alias = attributes.Remove("alias");

            Register(path, alias);
        }
示例#4
0
        // public methods

        /// <summary>
        /// Alters the attributes of this Section.
        /// </summary>
        /// <param name="attributes">the attributes</param>
        public void Set(itextProperties attributes)
        {
            string value;

            if ((value = attributes.Remove(ElementTags.NUMBERDEPTH)) != null)
            {
                NumberDepth = int.Parse(value);
            }
            if ((value = attributes.Remove(ElementTags.INDENT)) != null)
            {
                Indentation = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }
            if ((value = attributes.Remove(ElementTags.INDENTATIONLEFT)) != null)
            {
                IndentationLeft = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }
            if ((value = attributes.Remove(ElementTags.INDENTATIONRIGHT)) != null)
            {
                IndentationRight = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }
        }
示例#5
0
        public HeaderFooter(itextProperties attributes) : base(0, 0, 0, 0)
        {
            string value;

            if ((value = attributes.Remove(ElementTags.NUMBERED)) != null)
            {
                this.numbered = bool.Parse(value);
            }
            if ((value = attributes.Remove(ElementTags.ALIGN)) != null)
            {
                this.SetAlignment(value);
            }
            if ((value = attributes.Remove("border")) != null)
            {
                this.Border = int.Parse(value);
            }
            else
            {
                this.Border = TOP_BORDER + BOTTOM_BORDER;
            }
        }
示例#6
0
        public static Anchor GetAnchor(itextProperties attributes)
        {
            Anchor anchor = new Anchor(GetPhrase(attributes));
            String value;

            value = attributes[ElementTags.NAME];
            if (value != null)
            {
                anchor.Name = value;
            }
            value = (String)attributes.Remove(ElementTags.REFERENCE);
            if (value != null)
            {
                anchor.Reference = value;
            }
            return(anchor);
        }
示例#7
0
        /**
         * Creates an Annotation object based on a list of properties.
         * @param attributes
         * @return an Annotation
         */
        public static Annotation GetAnnotation(itextProperties attributes)
        {
            float  llx = 0, lly = 0, urx = 0, ury = 0;
            String value;

            value = attributes[ElementTags.LLX];
            if (value != null)
            {
                llx = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }
            value = attributes[ElementTags.LLY];
            if (value != null)
            {
                lly = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }
            value = attributes[ElementTags.URX];
            if (value != null)
            {
                urx = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }
            value = attributes[ElementTags.URY];
            if (value != null)
            {
                ury = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }

            String title = attributes[ElementTags.TITLE];
            String text  = attributes[ElementTags.CONTENT];

            if (title != null || text != null)
            {
                return(new Annotation(title, text, llx, lly, urx, ury));
            }
            value = attributes[ElementTags.URL];
            if (value != null)
            {
                return(new Annotation(llx, lly, urx, ury, value));
            }
            value = attributes[ElementTags.NAMED];
            if (value != null)
            {
                return(new Annotation(llx, lly, urx, ury, int.Parse(value)));
            }
            String file        = attributes[ElementTags.FILE];
            String destination = attributes[ElementTags.DESTINATION];
            String page        = (String)attributes.Remove(ElementTags.PAGE);

            if (file != null)
            {
                if (destination != null)
                {
                    return(new Annotation(llx, lly, urx, ury, file, destination));
                }
                if (page != null)
                {
                    return(new Annotation(llx, lly, urx, ury, file, int.Parse(page)));
                }
            }
            if (title == null)
            {
                title = "";
            }
            if (text == null)
            {
                text = "";
            }
            return(new Annotation(title, text, llx, lly, urx, ury));
        }
示例#8
0
        /**
         * Sets some Rectangle properties (for a Cell, Table,...).
         */
        private static void SetRectangleProperties(Rectangle rect, itextProperties attributes)
        {
            String value;

            value = attributes[ElementTags.BORDERWIDTH];
            if (value != null)
            {
                rect.BorderWidth = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }
            int border = 0;

            if (Utilities.CheckTrueOrFalse(attributes, ElementTags.LEFT))
            {
                border |= Rectangle.LEFT_BORDER;
            }
            if (Utilities.CheckTrueOrFalse(attributes, ElementTags.RIGHT))
            {
                border |= Rectangle.RIGHT_BORDER;
            }
            if (Utilities.CheckTrueOrFalse(attributes, ElementTags.TOP))
            {
                border |= Rectangle.TOP_BORDER;
            }
            if (Utilities.CheckTrueOrFalse(attributes, ElementTags.BOTTOM))
            {
                border |= Rectangle.BOTTOM_BORDER;
            }
            rect.Border = border;

            String r = attributes[ElementTags.RED];
            String g = attributes[ElementTags.GREEN];
            String b = attributes[ElementTags.BLUE];

            if (r != null || g != null || b != null)
            {
                int red   = 0;
                int green = 0;
                int blue  = 0;
                if (r != null)
                {
                    red = int.Parse(r);
                }
                if (g != null)
                {
                    green = int.Parse(g);
                }
                if (b != null)
                {
                    blue = int.Parse(b);
                }
                rect.BorderColor = new Color(red, green, blue);
            }
            else
            {
                rect.BorderColor = Markup.DecodeColor(attributes[ElementTags.BORDERCOLOR]);
            }
            r     = (String)attributes.Remove(ElementTags.BGRED);
            g     = (String)attributes.Remove(ElementTags.BGGREEN);
            b     = (String)attributes.Remove(ElementTags.BGBLUE);
            value = attributes[ElementTags.BACKGROUNDCOLOR];
            if (r != null || g != null || b != null)
            {
                int red   = 0;
                int green = 0;
                int blue  = 0;
                if (r != null)
                {
                    red = int.Parse(r);
                }
                if (g != null)
                {
                    green = int.Parse(g);
                }
                if (b != null)
                {
                    blue = int.Parse(b);
                }
                rect.BackgroundColor = new Color(red, green, blue);
            }
            else if (value != null)
            {
                rect.BackgroundColor = Markup.DecodeColor(value);
            }
            else
            {
                value = attributes[ElementTags.GRAYFILL];
                if (value != null)
                {
                    rect.GrayFill = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
                }
            }
        }