Beispiel #1
0
        public static Cell GetCell(itextProperties attributes)
        {
            Cell   cell = new Cell();
            String value;

            cell.SetHorizontalAlignment(attributes[ElementTags.HORIZONTALALIGN]);
            cell.SetVerticalAlignment(attributes[ElementTags.VERTICALALIGN]);
            value = attributes[ElementTags.WIDTH];
            if (value != null)
            {
                cell.SetWidth(value);
            }
            value = attributes[ElementTags.COLSPAN];
            if (value != null)
            {
                cell.Colspan = int.Parse(value);
            }
            value = attributes[ElementTags.ROWSPAN];
            if (value != null)
            {
                cell.Rowspan = int.Parse(value);
            }
            value = attributes[ElementTags.LEADING];
            if (value != null)
            {
                cell.Leading = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }
            cell.Header = Utilities.CheckTrueOrFalse(attributes, ElementTags.HEADER);
            if (Utilities.CheckTrueOrFalse(attributes, ElementTags.NOWRAP))
            {
                cell.MaxLines = 1;
            }
            SetRectangleProperties(cell, attributes);
            return(cell);
        }
Beispiel #2
0
        public static Phrase GetPhrase(itextProperties attributes)
        {
            Phrase phrase = new Phrase();

            phrase.Font = FontFactory.GetFont(attributes);
            String value;

            value = attributes[ElementTags.LEADING];
            if (value != null)
            {
                phrase.Leading = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }
            value = attributes[Markup.CSS_KEY_LINEHEIGHT];
            if (value != null)
            {
                phrase.Leading = Markup.ParseLength(value, Markup.DEFAULT_FONT_SIZE);
            }
            value = attributes[ElementTags.ITEXT];
            if (value != null)
            {
                Chunk chunk = new Chunk(value);
                if ((value = attributes[ElementTags.GENERICTAG]) != null)
                {
                    chunk.SetGenericTag(value);
                }
                phrase.Add(chunk);
            }
            return(phrase);
        }
Beispiel #3
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);
 }
Beispiel #4
0
 private static void LoadProperties()
 {
     if (propertiesLoaded)
     {
         return;
     }
     lock (allFonts) {
         if (propertiesLoaded)
         {
             return;
         }
         try {
             Stream isp = GetResourceStream(RESOURCE_PATH + "cjkfonts.properties");
             cjkFonts.Load(isp);
             isp.Close();
             isp = GetResourceStream(RESOURCE_PATH + "cjkencodings.properties");
             cjkEncodings.Load(isp);
             isp.Close();
         }
         catch {
             cjkFonts     = new itextProperties();
             cjkEncodings = new itextProperties();
         }
         propertiesLoaded = true;
     }
 }
Beispiel #5
0
        public static ChapterAutoNumber GetChapter(itextProperties attributes)
        {
            ChapterAutoNumber chapter = new ChapterAutoNumber("");

            SetSectionParameters(chapter, attributes);
            return(chapter);
        }
Beispiel #6
0
        public static Section GetSection(Section parent, itextProperties attributes)
        {
            Section section = parent.AddSection("");

            SetSectionParameters(section, attributes);
            return(section);
        }
Beispiel #7
0
        private static void SetSectionParameters(Section section, itextProperties attributes)
        {
            String value;

            value = attributes[ElementTags.NUMBERDEPTH];
            if (value != null)
            {
                section.NumberDepth = int.Parse(value);
            }
            value = attributes[ElementTags.INDENT];
            if (value != null)
            {
                section.Indentation = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }
            value = attributes[ElementTags.INDENTATIONLEFT];
            if (value != null)
            {
                section.IndentationLeft = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }
            value = attributes[ElementTags.INDENTATIONRIGHT];
            if (value != null)
            {
                section.IndentationRight = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }
        }
Beispiel #8
0
        public virtual void Register(itextProperties attributes)
        {
            string path;
            string alias = null;

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

            Register(path, alias);
        }
Beispiel #9
0
        public static void Register(itextProperties attributes)
        {
            string path;
            string alias = null;

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

            fontImp.Register(path, alias);
        }
Beispiel #10
0
        public static List GetList(itextProperties attributes)
        {
            List list = new List();

            list.Numbered    = Utilities.CheckTrueOrFalse(attributes, ElementTags.NUMBERED);
            list.Lettered    = Utilities.CheckTrueOrFalse(attributes, ElementTags.LETTERED);
            list.Lowercase   = Utilities.CheckTrueOrFalse(attributes, ElementTags.LOWERCASE);
            list.Autoindent  = Utilities.CheckTrueOrFalse(attributes, ElementTags.AUTO_INDENT_ITEMS);
            list.Alignindent = Utilities.CheckTrueOrFalse(attributes, ElementTags.ALIGN_INDENTATION_ITEMS);

            String value;

            value = attributes[ElementTags.FIRST];
            if (value != null)
            {
                char character = value[0];
                if (char.IsLetter(character))
                {
                    list.First = (int)character;
                }
                else
                {
                    list.First = int.Parse(value);
                }
            }

            value = attributes[ElementTags.LISTSYMBOL];
            if (value != null)
            {
                list.ListSymbol = new Chunk(value, FontFactory.GetFont(attributes));
            }

            value = attributes[ElementTags.INDENTATIONLEFT];
            if (value != null)
            {
                list.IndentationLeft = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }

            value = attributes[ElementTags.INDENTATIONRIGHT];
            if (value != null)
            {
                list.IndentationRight = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }

            value = attributes[ElementTags.SYMBOLINDENT];
            if (value != null)
            {
                list.SymbolIndent = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }

            return(list);
        }
Beispiel #11
0
        /// <summary>
        /// This method gets called when a start tag is encountered.
        /// </summary>
        /// <param name="uri"></param>
        /// <param name="lname"></param>
        /// <param name="name">the name of the tag that is encountered</param>
        /// <param name="attrs">the list of attributes</param>
        public override void StartElement(String uri, String lname, String name, Hashtable attrs)
        {
            itextProperties attributes = new itextProperties();

            if (attrs != null)
            {
                foreach (string key in attrs.Keys)
                {
                    attributes.Add(key, (string)attrs[key]);
                }
            }
            HandleStartingTags(name, attributes);
        }
Beispiel #12
0
 /// <summary>
 /// Writes the markup attributes of the specified MarkupAttributes
 /// object to the stream.
 /// </summary>
 /// <param name="mAtt">the MarkupAttributes to write.</param>
 /// <returns></returns>
 protected bool WriteMarkupAttributes(itextProperties markup)
 {
     if (markup == null)
     {
         return(false);
     }
     foreach (String name in markup.Keys)
     {
         Write(name, markup[name]);
     }
     markup.Clear();
     return(true);
 }
Beispiel #13
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);
        }
Beispiel #14
0
        /**
         * @see com.lowagie.text.xml.XmlPeer#getAttributes(org.xml.sax.Attributes)
         */
        public override itextProperties GetAttributes(Hashtable attrs)
        {
            itextProperties attributes = new itextProperties();

            attributes.AddAll(attributeValues);
            if (defaultContent != null)
            {
                attributes[ElementTags.ITEXT] = defaultContent;
            }
            if (attrs != null)
            {
                foreach (string key in attrs.Keys)
                {
                    attributes.Add(GetName(key).ToLower(CultureInfo.InvariantCulture), (string)attrs[key]);
                }
            }
            return(attributes);
        }
Beispiel #15
0
        /// <summary> Gets the list of attributes of the peer. </summary>
        public virtual itextProperties GetAttributes(Hashtable attrs)
        {
            itextProperties attributes = new itextProperties();

            attributes.AddAll(attributeValues);
            if (defaultContent != null)
            {
                attributes.Add(ElementTags.ITEXT, defaultContent);
            }
            if (attrs != null)
            {
                foreach (string key in attrs.Keys)
                {
                    attributes.Add(GetName(key), (string)attrs[key]);
                }
            }
            return(attributes);
        }
Beispiel #16
0
        /// <summary>
        /// This method parses a string with attributes and returns a itextProperties object.
        /// </summary>
        /// <param name="str">a string of this form: 'key1="value1"; key2="value2";... keyN="valueN" '</param>
        /// <returns>a itextProperties object</returns>
        public static itextProperties ParseAttributes(string str)
        {
            itextProperties result = new itextProperties();

            if (str == null)
            {
                return(result);
            }
            StringTokenizer keyValuePairs = new StringTokenizer(str, ";");
            StringTokenizer keyValuePair;
            string          key;
            string          value;

            while (keyValuePairs.HasMoreTokens())
            {
                keyValuePair = new StringTokenizer(keyValuePairs.NextToken(), ":");
                if (keyValuePair.HasMoreTokens())
                {
                    key = keyValuePair.NextToken().Trim().Trim();
                }
                else
                {
                    continue;
                }
                if (keyValuePair.HasMoreTokens())
                {
                    value = keyValuePair.NextToken().Trim();
                }
                else
                {
                    continue;
                }
                if (value.StartsWith("\""))
                {
                    value = value.Substring(1);
                }
                if (value.EndsWith("\""))
                {
                    value = value.Substring(0, value.Length - 1);
                }
                result.Add(key.ToLower(CultureInfo.InvariantCulture), value);
            }
            return(result);
        }
Beispiel #17
0
 /// <summary>
 /// This method gets called when a start tag is encountered.
 /// </summary>
 /// <param name="uri"></param>
 /// <param name="lname"></param>
 /// <param name="name">the name of the tag that is encountered</param>
 /// <param name="attrs">the list of attributes</param>
 public override void StartElement(String uri, String lname, String name, Hashtable attrs)
 {
     if (myTags.ContainsKey(name))
     {
         XmlPeer peer = (XmlPeer)myTags[name];
         HandleStartingTags(peer.Tag, peer.GetAttributes(attrs));
     }
     else
     {
         itextProperties attributes = new itextProperties();
         if (attrs != null)
         {
             foreach (string key in attrs.Keys)
             {
                 attributes.Add(key, (string)attrs[key]);
             }
         }
         HandleStartingTags(name, attributes);
     }
 }
Beispiel #18
0
        /**
         * Writes the HTML representation of a section.
         *
         * @param   section     the section to write
         * @param   indent      the indentation
         */

        protected void WriteSection(Section section, int indent)
        {
            if (section.Title != null)
            {
                int depth = section.Depth - 1;
                if (depth > 5)
                {
                    depth = 5;
                }
                itextProperties styleAttributes = new itextProperties();
                if (section.Title.HasLeading())
                {
                    styleAttributes[Markup.CSS_KEY_LINEHEIGHT] = section.Title.TotalLeading.ToString() + "pt";
                }
                // start tag
                AddTabs(indent);
                WriteStart(HtmlTags.H[depth]);
                Write(section.Title.Font, styleAttributes);
                String alignment = HtmlEncoder.GetAlignment(section.Title.Alignment);
                if (!"".Equals(alignment))
                {
                    Write(HtmlTags.ALIGN, alignment);
                }
                WriteMarkupAttributes(markup);
                os.WriteByte(GT);
                currentfont.Push(section.Title.Font);
                // contents
                foreach (IElement i in section.Title)
                {
                    Write(i, indent + 1);
                }
                // end tag
                AddTabs(indent);
                WriteEnd(HtmlTags.H[depth]);
                currentfont.Pop();
            }
            foreach (IElement i in section)
            {
                Write(i, indent);
            }
        }
Beispiel #19
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);
            }
        }
Beispiel #20
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;
            }
        }
Beispiel #21
0
        public static Paragraph GetParagraph(itextProperties attributes)
        {
            Paragraph paragraph = new Paragraph(GetPhrase(attributes));
            String    value;

            value = attributes[ElementTags.ALIGN];
            if (value != null)
            {
                paragraph.SetAlignment(value);
            }
            value = attributes[ElementTags.INDENTATIONLEFT];
            if (value != null)
            {
                paragraph.IndentationLeft = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }
            value = attributes[ElementTags.INDENTATIONRIGHT];
            if (value != null)
            {
                paragraph.IndentationRight = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }
            return(paragraph);
        }
Beispiel #22
0
 /// <summary>
 /// Constructs a Font-object.
 /// </summary>
 /// <param name="attributes">the attributes of a Font object</param>
 /// <returns>a Font object</returns>
 public static Font GetFont(itextProperties attributes)
 {
     fontImp.DefaultEmbedding = defaultEmbedding;
     fontImp.DefaultEncoding  = defaultEncoding;
     return(fontImp.GetFont(attributes));
 }
Beispiel #23
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="table"></param>
 /// <returns></returns>
 public static ICollection GetKeySet(itextProperties table)
 {
     return((table == null) ? new itextProperties().Keys : table.Keys);
 }
Beispiel #24
0
 /**
  * Checks for a true/false value of a key in a itextProperties object.
  * @param attributes
  * @param key
  * @return
  */
 public static bool CheckTrueOrFalse(itextProperties attributes, String key)
 {
     return(Util.EqualsIgnoreCase("true", attributes[key]));
 }
Beispiel #25
0
        public static Chunk GetChunk(itextProperties attributes)
        {
            Chunk chunk = new Chunk();

            chunk.Font = FontFactory.GetFont(attributes);
            String value;

            value = attributes[ElementTags.ITEXT];
            if (value != null)
            {
                chunk.Append(value);
            }
            value = attributes[ElementTags.LOCALGOTO];
            if (value != null)
            {
                chunk.SetLocalGoto(value);
            }
            value = attributes[ElementTags.REMOTEGOTO];
            if (value != null)
            {
                String page = attributes[ElementTags.PAGE];
                if (page != null)
                {
                    chunk.SetRemoteGoto(value, int.Parse(page));
                }
                else
                {
                    String destination = attributes[ElementTags.DESTINATION];
                    if (destination != null)
                    {
                        chunk.SetRemoteGoto(value, destination);
                    }
                }
            }
            value = attributes[ElementTags.LOCALDESTINATION];
            if (value != null)
            {
                chunk.SetLocalDestination(value);
            }
            value = attributes[ElementTags.SUBSUPSCRIPT];
            if (value != null)
            {
                chunk.SetTextRise(float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo));
            }
            value = attributes[Markup.CSS_KEY_VERTICALALIGN];
            if (value != null && value.EndsWith("%"))
            {
                float p = float.Parse(value.Substring(0, value.Length - 1), System.Globalization.NumberFormatInfo.InvariantInfo) / 100f;
                chunk.SetTextRise(p * chunk.Font.Size);
            }
            value = attributes[ElementTags.GENERICTAG];
            if (value != null)
            {
                chunk.SetGenericTag(value);
            }
            value = attributes[ElementTags.BACKGROUNDCOLOR];
            if (value != null)
            {
                chunk.SetBackground(Markup.DecodeColor(value));
            }
            return(chunk);
        }
Beispiel #26
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));
        }
Beispiel #27
0
        /// <summary>
        /// Returns an Image that has been constructed taking in account
        /// the value of some attributes.
        /// </summary>
        /// <param name="attributes">Some attributes</param>
        /// <returns>an Image</returns>
        public static Image GetImage(itextProperties attributes)
        {
            String value;

            value = attributes[ElementTags.URL];
            if (value == null)
            {
                throw new ArgumentException("The URL of the image is missing.");
            }
            Image image = Image.GetInstance(value);

            value = attributes[ElementTags.ALIGN];
            int align = 0;

            if (value != null)
            {
                if (Util.EqualsIgnoreCase(ElementTags.ALIGN_LEFT, value))
                {
                    align |= Image.ALIGN_LEFT;
                }
                else if (Util.EqualsIgnoreCase(ElementTags.ALIGN_RIGHT, value))
                {
                    align |= Image.ALIGN_RIGHT;
                }
                else if (Util.EqualsIgnoreCase(ElementTags.ALIGN_MIDDLE, value))
                {
                    align |= Image.ALIGN_MIDDLE;
                }
            }
            if (Util.EqualsIgnoreCase("true", attributes[ElementTags.UNDERLYING]))
            {
                align |= Image.UNDERLYING;
            }
            if (Util.EqualsIgnoreCase("true", attributes[ElementTags.TEXTWRAP]))
            {
                align |= Image.TEXTWRAP;
            }
            image.Alignment = align;

            value = attributes[ElementTags.ALT];
            if (value != null)
            {
                image.Alt = value;
            }

            String x = attributes[ElementTags.ABSOLUTEX];
            String y = attributes[ElementTags.ABSOLUTEY];

            if ((x != null) && (y != null))
            {
                image.SetAbsolutePosition(float.Parse(x, System.Globalization.NumberFormatInfo.InvariantInfo),
                                          float.Parse(y, System.Globalization.NumberFormatInfo.InvariantInfo));
            }
            value = attributes[ElementTags.PLAINWIDTH];
            if (value != null)
            {
                image.ScaleAbsoluteWidth(float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo));
            }
            value = attributes[ElementTags.PLAINHEIGHT];
            if (value != null)
            {
                image.ScaleAbsoluteHeight(float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo));
            }
            value = attributes[ElementTags.ROTATION];
            if (value != null)
            {
                image.Rotation = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }
            return(image);
        }
Beispiel #28
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);
                }
            }
        }
Beispiel #29
0
        /**
         * Creates an Table object based on a list of properties.
         * @param attributes
         * @return a Table
         */
        public static Table GetTable(itextProperties attributes)
        {
            String value;
            Table  table;

            value = attributes[ElementTags.WIDTHS];
            if (value != null)
            {
                StringTokenizer widthTokens = new StringTokenizer(value, ";");
                ArrayList       values      = new ArrayList();
                while (widthTokens.HasMoreTokens())
                {
                    values.Add(widthTokens.NextToken());
                }
                table = new Table(values.Count);
                float[] widths = new float[table.Columns];
                for (int i = 0; i < values.Count; i++)
                {
                    value     = (String)values[i];
                    widths[i] = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
                }
                table.Widths = widths;
            }
            else
            {
                value = attributes[ElementTags.COLUMNS];
                try {
                    table = new Table(int.Parse(value));
                }
                catch {
                    table = new Table(1);
                }
            }

            table.Border             = Table.BOX;
            table.BorderWidth        = 1;
            table.DefaultCell.Border = Table.BOX;

            value = attributes[ElementTags.LASTHEADERROW];
            if (value != null)
            {
                table.LastHeaderRow = int.Parse(value);
            }
            value = attributes[ElementTags.ALIGN];
            if (value != null)
            {
                table.SetAlignment(value);
            }
            value = attributes[ElementTags.CELLSPACING];
            if (value != null)
            {
                table.Spacing = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }
            value = attributes[ElementTags.CELLPADDING];
            if (value != null)
            {
                table.Padding = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }
            value = attributes[ElementTags.OFFSET];
            if (value != null)
            {
                table.Offset = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }
            value = attributes[ElementTags.WIDTH];
            if (value != null)
            {
                if (value.EndsWith("%"))
                {
                    table.Width = float.Parse(value.Substring(0, value.Length - 1), System.Globalization.NumberFormatInfo.InvariantInfo);
                }
                else
                {
                    table.Width  = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    table.Locked = true;
                }
            }
            table.TableFitsPage     = Utilities.CheckTrueOrFalse(attributes, ElementTags.TABLEFITSPAGE);
            table.CellsFitPage      = Utilities.CheckTrueOrFalse(attributes, ElementTags.CELLSFITPAGE);
            table.Convert2pdfptable = Utilities.CheckTrueOrFalse(attributes, ElementTags.CONVERT2PDFP);

            SetRectangleProperties(table, attributes);
            return(table);
        }
Beispiel #30
0
        public static ListItem GetListItem(itextProperties attributes)
        {
            ListItem item = new ListItem(GetParagraph(attributes));

            return(item);
        }