Exemple #1
0
 /**
  * Gets a HyphenationEvent based on the hyphenation entry in ChainedProperties.
  * @param    props   ChainedProperties
  * @return   a HyphenationEvent
  * @since    2.1.2
  */
 public static IHyphenationEvent GetHyphenation(ChainedProperties props)
 {
     return(GetHyphenation(props["hyphenation"]));
 }
Exemple #2
0
        /**
         * New method contributed by Lubos Strapko
         * @param h
         * @param cprops
         * @since 2.1.3
         */
        public static void InsertStyle(Hashtable h, ChainedProperties cprops)
        {
            String style = (String)h["style"];

            if (style == null)
            {
                return;
            }
            itextProperties prop = Markup.ParseAttributes(style);

            foreach (String key in prop.Keys)
            {
                if (key.Equals(Markup.CSS_KEY_FONTFAMILY))
                {
                    h["face"] = prop[key];
                }
                else if (key.Equals(Markup.CSS_KEY_FONTSIZE))
                {
                    float actualFontSize = Markup.ParseLength(cprops[ElementTags.SIZE], Markup.DEFAULT_FONT_SIZE);
                    if (actualFontSize <= 0f)
                    {
                        actualFontSize = Markup.DEFAULT_FONT_SIZE;
                    }
                    h[ElementTags.SIZE] = Markup.ParseLength(prop[key], actualFontSize).ToString(NumberFormatInfo.InvariantInfo) + "pt";
                }
                else if (key.Equals(Markup.CSS_KEY_FONTSTYLE))
                {
                    String ss = prop[key].Trim().ToLower(CultureInfo.InvariantCulture);
                    if (ss.Equals("italic") || ss.Equals("oblique"))
                    {
                        h["i"] = null;
                    }
                }
                else if (key.Equals(Markup.CSS_KEY_FONTWEIGHT))
                {
                    String ss = prop[key].Trim().ToLower(CultureInfo.InvariantCulture);
                    if (ss.Equals("bold") || ss.Equals("700") || ss.Equals("800") || ss.Equals("900"))
                    {
                        h["b"] = null;
                    }
                }
                else if (key.Equals(Markup.CSS_KEY_TEXTDECORATION))
                {
                    String ss = prop[key].Trim().ToLower(CultureInfo.InvariantCulture);
                    if (ss.Equals(Markup.CSS_VALUE_UNDERLINE))
                    {
                        h["u"] = null;
                    }
                }
                else if (key.Equals(Markup.CSS_KEY_COLOR))
                {
                    Color c = Markup.DecodeColor(prop[key]);
                    if (c != null)
                    {
                        int    hh = c.ToArgb() & 0xffffff;
                        String hs = "#" + hh.ToString("X06", NumberFormatInfo.InvariantInfo);
                        h["color"] = hs;
                    }
                }
                else if (key.Equals(Markup.CSS_KEY_LINEHEIGHT))
                {
                    String ss             = prop[key].Trim();
                    float  actualFontSize = Markup.ParseLength(cprops[ElementTags.SIZE], Markup.DEFAULT_FONT_SIZE);
                    if (actualFontSize <= 0f)
                    {
                        actualFontSize = Markup.DEFAULT_FONT_SIZE;
                    }
                    float v = Markup.ParseLength(prop[key], actualFontSize);
                    if (ss.EndsWith("%"))
                    {
                        v           /= 100;
                        h["leading"] = "0," + v.ToString(NumberFormatInfo.InvariantInfo);
                    }
                    else if (Util.EqualsIgnoreCase("normal", ss))
                    {
                        h["leading"] = "0,1.5";
                    }
                    else
                    {
                        h["leading"] = v.ToString(NumberFormatInfo.InvariantInfo) + ",0";
                    }
                }
                else if (key.Equals(Markup.CSS_KEY_TEXTALIGN))
                {
                    String ss = prop[key].Trim().ToLower(System.Globalization.CultureInfo.InvariantCulture);
                    h["align"] = ss;
                }
                else if (key.Equals(Markup.CSS_KEY_PADDINGLEFT))
                {
                    String ss = prop[key].Trim().ToLower(System.Globalization.CultureInfo.InvariantCulture);
                    h["indent"] = ss;
                }
            }
        }
Exemple #3
0
        /** Creates a new instance of IncCell */
        public IncCell(String tag, ChainedProperties props)
        {
            cell = new PdfPCell();
            String value = props["colspan"];

            if (value != null)
            {
                cell.Colspan = int.Parse(value);
            }
            value = props["align"];
            if (tag.Equals("th"))
            {
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
            }
            if (value != null)
            {
                if (Util.EqualsIgnoreCase(value, "center"))
                {
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                }
                else if (Util.EqualsIgnoreCase(value, "right"))
                {
                    cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                }
                else if (Util.EqualsIgnoreCase(value, "left"))
                {
                    cell.HorizontalAlignment = Element.ALIGN_LEFT;
                }
                else if (Util.EqualsIgnoreCase(value, "justify"))
                {
                    cell.HorizontalAlignment = Element.ALIGN_JUSTIFIED;
                }
            }
            value = props["valign"];
            cell.VerticalAlignment = Element.ALIGN_MIDDLE;
            if (value != null)
            {
                if (Util.EqualsIgnoreCase(value, "top"))
                {
                    cell.VerticalAlignment = Element.ALIGN_TOP;
                }
                else if (Util.EqualsIgnoreCase(value, "bottom"))
                {
                    cell.VerticalAlignment = Element.ALIGN_BOTTOM;
                }
            }
            value = props["border"];
            float border = 0;

            if (value != null)
            {
                border = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }
            cell.BorderWidth = border;
            value            = props["cellpadding"];
            if (value != null)
            {
                cell.Padding = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }
            cell.UseDescender    = true;
            value                = props["bgcolor"];
            cell.BackgroundColor = Markup.DecodeColor(value);
        }