Ejemplo n.º 1
0
 public static Anchor GetAnchor(Properties 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;
 }
Ejemplo n.º 2
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 {
         Properties attributes = new Properties();
         if (attrs != null) {
             foreach (string key in attrs.Keys) {
                 attributes.Add(key, (string)attrs[key]);
             }
         }
         HandleStartingTags(name, attributes);
     }
 }
Ejemplo n.º 3
0
 internal static Hashtable ReadFontProperties(String name)
 {
     try {
     name += ".properties";
     Stream isp = GetResourceStream(RESOURCE_PATH + name);
     Properties p = new Properties();
     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;
 }
Ejemplo n.º 4
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(Properties attributes)
 {
     fontImp.DefaultEmbedding = defaultEmbedding;
     fontImp.DefaultEncoding = defaultEncoding;
     return fontImp.GetFont(attributes);
 }
Ejemplo n.º 5
0
 /**
 * @see com.lowagie.text.xml.XmlPeer#getAttributes(org.xml.sax.Attributes)
 */
 public override Properties GetAttributes(Hashtable attrs)
 {
     Properties attributes = new Properties();
     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;
 }
Ejemplo n.º 6
0
 public static Section GetSection(Section parent, Properties attributes)
 {
     Section section = parent.AddSection("");
     SetSectionParameters(section, attributes);
     return section;
 }
Ejemplo n.º 7
0
        /**
        * Sets some Rectangle properties (for a Cell, Table,...).
        */
        private static void SetRectangleProperties(Rectangle rect, Properties attributes)
        {
            String value;
            value = attributes[ElementTags.BORDERWIDTH];
            if (value != null) {
                rect.BorderWidth = float.Parse(value, 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, NumberFormatInfo.InvariantInfo);
                }
            }
        }
Ejemplo n.º 8
0
        public virtual void Register(Properties attributes)
        {
            string path;
            string alias = null;

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

            Register(path, alias);
        }
Ejemplo n.º 9
0
        /**
        * This method gets called when a start tag is encountered.
        *
        * @param   uri         the Uniform Resource Identifier
        * @param   lname       the local name (without prefix), or the empty string if Namespace processing is not being performed.
        * @param   name        the name of the tag that is encountered
        * @param   attrs       the list of attributes
        */
        public override void StartElement(String uri, String lname, String name, Hashtable attrs)
        {
            //System.err.Println("Start: " + name);

            // super.handleStartingTags is replaced with handleStartingTags
            // suggestion by Vu Ngoc Tan/Hop
            name = name.ToLower(CultureInfo.InvariantCulture);
            if (HtmlTagMap.IsHtml(name)) {
                // we do nothing
                return;
            }
            if (HtmlTagMap.IsHead(name)) {
                // we do nothing
                return;
            }
            if (HtmlTagMap.IsTitle(name)) {
                // we do nothing
                return;
            }
            if (HtmlTagMap.IsMeta(name)) {
                // we look if we can change the body attributes
                String meta = null;
                String content = null;
                if (attrs != null) {
                    foreach (String attribute in attrs.Keys) {
                        if (Util.EqualsIgnoreCase(attribute, HtmlTags.CONTENT))
                            content = (String)attrs[attribute];
                        else if (Util.EqualsIgnoreCase(attribute, HtmlTags.NAME))
                            meta = (String)attrs[attribute];
                    }
                }
                if (meta != null && content != null) {
                    bodyAttributes.Add(meta, content);
                }
                return;
            }
            if (HtmlTagMap.IsLink(name)) {
                // we do nothing for the moment, in a later version we could extract the style sheet
                return;
            }
            if (HtmlTagMap.IsBody(name)) {
                // maybe we could extract some info about the document: color, margins,...
                // but that's for a later version...
                XmlPeer peer = new XmlPeer(ElementTags.ITEXT, name);
                peer.AddAlias(ElementTags.TOP, HtmlTags.TOPMARGIN);
                peer.AddAlias(ElementTags.BOTTOM, HtmlTags.BOTTOMMARGIN);
                peer.AddAlias(ElementTags.RIGHT, HtmlTags.RIGHTMARGIN);
                peer.AddAlias(ElementTags.LEFT, HtmlTags.LEFTMARGIN);
                bodyAttributes.AddAll(peer.GetAttributes(attrs));
                HandleStartingTags(peer.Tag, bodyAttributes);
                return;
            }
            if (myTags.ContainsKey(name)) {
                XmlPeer peer = (XmlPeer) myTags[name];
                if (ElementTags.TABLE.Equals(peer.Tag) || ElementTags.CELL.Equals(peer.Tag)) {
                    Properties p = peer.GetAttributes(attrs);
                    String value;
                    if (ElementTags.TABLE.Equals(peer.Tag) && (value = p[ElementTags.BORDERWIDTH]) != null) {
                        if (float.Parse(value, NumberFormatInfo.InvariantInfo) > 0) {
                            tableBorder = true;
                        }
                    }
                    if (tableBorder) {
                        p.Add(ElementTags.LEFT, "true");
                        p.Add(ElementTags.RIGHT, "true");
                        p.Add(ElementTags.TOP, "true");
                        p.Add(ElementTags.BOTTOM, "true");
                    }
                    HandleStartingTags(peer.Tag, p);
                    return;
                }
                HandleStartingTags(peer.Tag, peer.GetAttributes(attrs));
                return;
            }
            Properties attributes = new Properties();
            if (attrs != null) {
                foreach (String attribute in attrs.Keys) {
                    attributes.Add(attribute.ToLower(CultureInfo.InvariantCulture), ((String)attrs[attribute]).ToLower(CultureInfo.InvariantCulture));
                }
            }
            HandleStartingTags(name, attributes);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="table"></param>
 /// <returns></returns>
 public static ICollection GetKeySet(Properties table)
 {
     return (table == null) ? new Properties().Keys : table.Keys;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Constructs a Font-object.
 /// </summary>
 /// <param name="attributes">the attributes of a Font object</param>
 /// <returns>a Font object</returns>
 public virtual Font GetFont(Properties attributes)
 {
     string fontname = null;
     string encoding = defaultEncoding;
     bool embedded = defaultEmbedding;
     float size = Font.UNDEFINED;
     int style = Font.NORMAL;
     Color color = null;
     string value = attributes[Markup.HTML_ATTR_STYLE];
     if (value != null && value.Length > 0) {
         Properties styleAttributes = Markup.ParseAttributes(value);
         if (styleAttributes.Count == 0) {
             attributes.Add(Markup.HTML_ATTR_STYLE, value);
         }
         else {
             fontname = styleAttributes[Markup.CSS_KEY_FONTFAMILY];
             if (fontname != null) {
                 string tmp;
                 while (fontname.IndexOf(',') != -1) {
                     tmp = fontname.Substring(0, fontname.IndexOf(','));
                     if (IsRegistered(tmp)) {
                         fontname = tmp;
                     }
                     else {
                         fontname = fontname.Substring(fontname.IndexOf(',') + 1);
                     }
                 }
             }
             if ((value = styleAttributes[Markup.CSS_KEY_FONTSIZE]) != null) {
                 size = Markup.ParseLength(value);
             }
             if ((value = styleAttributes[Markup.CSS_KEY_FONTWEIGHT]) != null) {
                 style |= Font.GetStyleValue(value);
             }
             if ((value = styleAttributes[Markup.CSS_KEY_FONTSTYLE]) != null) {
                 style |= Font.GetStyleValue(value);
             }
             if ((value = styleAttributes[Markup.CSS_KEY_COLOR]) != null) {
                 color = Markup.DecodeColor(value);
             }
             attributes.AddAll(styleAttributes);
         }
     }
     if ((value = attributes[ElementTags.ENCODING]) != null) {
         encoding = value;
     }
     if ("true".Equals(attributes[ElementTags.EMBEDDED])) {
         embedded = true;
     }
     if ((value = attributes[ElementTags.FONT]) != null) {
         fontname = value;
     }
     if ((value = attributes[ElementTags.SIZE]) != null) {
         size = float.Parse(value, NumberFormatInfo.InvariantInfo);
     }
     if ((value = attributes[Markup.HTML_ATTR_STYLE]) != null) {
         style |= Font.GetStyleValue(value);
     }
     if ((value = attributes[ElementTags.STYLE]) != null) {
         style |= Font.GetStyleValue(value);
     }
     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);
         color = new Color(red, green, blue);
     }
     else if ((value = attributes[ElementTags.COLOR]) != null) {
         color = Markup.DecodeColor(value);
     }
     if (fontname == null) {
         return GetFont(null, encoding, embedded, size, style, color);
     }
     return GetFont(fontname, encoding, embedded, size, style, color);
 }
Ejemplo n.º 12
0
 /**
 * Checks for a true/false value of a key in a Properties object.
 * @param attributes
 * @param key
 * @return
 */
 public static bool CheckTrueOrFalse(Properties attributes, String key)
 {
     return Util.EqualsIgnoreCase("true", attributes[key]);
 }
Ejemplo n.º 13
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(Properties markup)
 {
     if (markup == null) return false;
     foreach (String name in markup.Keys) {
         Write(name, markup[name]);
     }
     markup.Clear();
     return true;
 }
Ejemplo n.º 14
0
 // public methods
 /// <summary>
 /// Alters the attributes of this Section.
 /// </summary>
 /// <param name="attributes">the attributes</param>
 public void Set(Properties 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, NumberFormatInfo.InvariantInfo);
     }
     if ((value = attributes.Remove(ElementTags.INDENTATIONLEFT)) != null) {
         IndentationLeft = float.Parse(value, NumberFormatInfo.InvariantInfo);
     }
     if ((value = attributes.Remove(ElementTags.INDENTATIONRIGHT)) != null) {
         IndentationRight = float.Parse(value, NumberFormatInfo.InvariantInfo);
     }
 }
Ejemplo n.º 15
0
 public static Paragraph GetParagraph(Properties 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, NumberFormatInfo.InvariantInfo);
     }
     value = attributes[ElementTags.INDENTATIONRIGHT];
     if (value != null) {
         paragraph.IndentationRight = float.Parse(value, NumberFormatInfo.InvariantInfo);
     }
     return paragraph;
 }
Ejemplo n.º 16
0
 /// <summary>
 /// This method parses a string with attributes and returns a Properties object.
 /// </summary>
 /// <param name="str">a string of this form: 'key1="value1"; key2="value2";... keyN="valueN" '</param>
 /// <returns>a Properties object</returns>
 public static Properties ParseAttributes(string str)
 {
     Properties result = new Properties();
     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;
 }
Ejemplo n.º 17
0
 public static Phrase GetPhrase(Properties attributes)
 {
     Phrase phrase = new Phrase();
     phrase.Font = FontFactory.GetFont(attributes);
     String value;
     value = attributes[ElementTags.LEADING];
     if (value != null) {
         phrase.Leading = float.Parse(value, 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;
 }
Ejemplo n.º 18
0
        public static Cell GetCell(Properties 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, NumberFormatInfo.InvariantInfo);
            }
            cell.Header = Utilities.CheckTrueOrFalse(attributes, ElementTags.HEADER);
            if (Utilities.CheckTrueOrFalse(attributes, ElementTags.NOWRAP)) {
                cell.MaxLines = 1;
            }
            SetRectangleProperties(cell, attributes);
            return cell;
        }
Ejemplo n.º 19
0
        /**
        * Creates an Table object based on a list of properties.
        * @param attributes
        * @return a Table
        */
        public static Table GetTable(Properties 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, 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, NumberFormatInfo.InvariantInfo);
            }
            value = attributes[ElementTags.CELLPADDING];
            if (value != null) {
                table.Padding = float.Parse(value, NumberFormatInfo.InvariantInfo);
            }
            value = attributes[ElementTags.OFFSET];
            if (value != null) {
                table.Offset = float.Parse(value, NumberFormatInfo.InvariantInfo);
            }
            value = attributes[ElementTags.WIDTH];
            if (value != null) {
                if (value.EndsWith("%"))
                    table.Width = float.Parse(value.Substring(0, value.Length - 1), NumberFormatInfo.InvariantInfo);
                else {
                    table.Width = float.Parse(value, 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;
        }
Ejemplo n.º 20
0
 public static ChapterAutoNumber GetChapter(Properties attributes)
 {
     ChapterAutoNumber chapter = new ChapterAutoNumber("");
     SetSectionParameters(chapter, attributes);
     return chapter;
 }
Ejemplo n.º 21
0
 private static void SetSectionParameters(Section section, Properties 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, NumberFormatInfo.InvariantInfo);
     }
     value = attributes[ElementTags.INDENTATIONLEFT];
     if (value != null) {
         section.IndentationLeft = float.Parse(value, NumberFormatInfo.InvariantInfo);
     }
     value = attributes[ElementTags.INDENTATIONRIGHT];
     if (value != null) {
         section.IndentationRight = float.Parse(value, NumberFormatInfo.InvariantInfo);
     }
 }
Ejemplo n.º 22
0
        public static Chunk GetChunk(Properties 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, NumberFormatInfo.InvariantInfo));
            }
            value = attributes[Markup.CSS_KEY_VERTICALALIGN];
            if (value != null && value.EndsWith("%")) {
                float p = float.Parse(value.Substring(0, value.Length - 1), 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;
        }
Ejemplo n.º 23
0
        /**
        * Creates an Annotation object based on a list of properties.
        * @param attributes
        * @return an Annotation
        */
        public static Annotation GetAnnotation(Properties attributes)
        {
            float llx = 0, lly = 0, urx = 0, ury = 0;
            String value;

            value = attributes[ElementTags.LLX];
            if (value != null) {
                llx = float.Parse(value, NumberFormatInfo.InvariantInfo);
            }
            value = attributes[ElementTags.LLY];
            if (value != null) {
                lly = float.Parse(value, NumberFormatInfo.InvariantInfo);
            }
            value = attributes[ElementTags.URX];
            if (value != null) {
                urx = float.Parse(value, NumberFormatInfo.InvariantInfo);
            }
            value = attributes[ElementTags.URY];
            if (value != null) {
                ury = float.Parse(value, 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);
        }
Ejemplo n.º 24
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(Properties 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, NumberFormatInfo.InvariantInfo),
                        float.Parse(y, NumberFormatInfo.InvariantInfo));
            }
            value = attributes[ElementTags.PLAINWIDTH];
            if (value != null) {
                image.ScaleAbsoluteWidth(float.Parse(value, NumberFormatInfo.InvariantInfo));
            }
            value = attributes[ElementTags.PLAINHEIGHT];
            if (value != null) {
                image.ScaleAbsoluteHeight(float.Parse(value, NumberFormatInfo.InvariantInfo));
            }
            value = attributes[ElementTags.ROTATION];
            if (value != null) {
                image.Rotation = float.Parse(value, NumberFormatInfo.InvariantInfo);
            }
            return image;
        }
Ejemplo n.º 25
0
        public HeaderFooter(Properties 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;
            }
        }
Ejemplo n.º 26
0
        public static List GetList(Properties 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, NumberFormatInfo.InvariantInfo);
            }

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

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

            return list;
        }
Ejemplo n.º 27
0
        public static void Register(Properties attributes)
        {
            string path;
            string alias = null;

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

            fontImp.Register(path, alias);
        }
Ejemplo n.º 28
0
 public static ListItem GetListItem(Properties attributes)
 {
     ListItem item = new ListItem(GetParagraph(attributes));
     return item;
 }
Ejemplo n.º 29
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 Properties();
         cjkEncodings = new Properties();
     }
     propertiesLoaded = true;
     }
 }
Ejemplo n.º 30
0
 public void AddAll(Properties col)
 {
     foreach (string itm in col.Keys) {
         _col[itm] = col[itm];
     }
 }