/// <summary> /// Returns a ListItem that has been constructed taking in account /// the value of some attributes. /// </summary> /// <param name="attributes">Some attributes</param> public ListItem(Properties attributes) : base("", FontFactory.getFont(attributes)) { string value; if ((value = attributes.Remove(ElementTags.ITEXT)) != null) { Add(new Chunk(value)); } if ((value = attributes.Remove(ElementTags.LEADING)) != null) { this.Leading = float.Parse(value); } else if ((value = attributes.Remove(MarkupTags.CSS_LINEHEIGHT)) != null) { this.Leading = MarkupParser.parseLength(value); } if ((value = attributes.Remove(ElementTags.INDENTATIONLEFT)) != null) { this.IndentationLeft = float.Parse(value); } if ((value = attributes.Remove(ElementTags.INDENTATIONRIGHT)) != null) { this.IndentationRight = float.Parse(value); } if ((value = attributes.Remove(ElementTags.ALIGN)) != null) { setAlignment(value); } if (attributes.Count > 0) { this.MarkupAttributes = attributes; } }
/// <summary> /// Returns a Phrase that has been constructed taking in account /// the value of some attributes. /// </summary> /// <param name="attributes">some attributes</param> public Phrase(Properties attributes) : this("", FontFactory.getFont(attributes)) { this.Clear(); string value; if ((value = attributes.Remove(ElementTags.LEADING)) != null) { Leading = float.Parse(value); } else if ((value = attributes.Remove(MarkupTags.CSS_LINEHEIGHT)) != null) { Leading = MarkupParser.parseLength(value); } if ((value = attributes.Remove(ElementTags.ITEXT)) != null) { Chunk chunk = new Chunk(value); if ((value = attributes.Remove(ElementTags.GENERICTAG)) != null) { chunk.setGenericTag(value); } Add(chunk); } if (attributes.Count > 0) { MarkupAttributes = attributes; } }
/// <summary> /// Returns a List that has been constructed taking in account /// the value of some attributes. /// </summary> /// <param name="attributes">Some attributes</param> public List(Properties attributes) { string value = attributes.Remove(ElementTags.LISTSYMBOL); if (value == null) { value = "-"; } symbol = new Chunk(value, FontFactory.getFont(attributes)); this.numbered = false; if ((value = attributes.Remove(ElementTags.NUMBERED)) != null) { this.numbered = bool.Parse(value); if (this.lettered && this.numbered) { this.lettered = false; } } if ((value = attributes.Remove(ElementTags.LETTERED)) != null) { this.lettered = bool.Parse(value); if (this.numbered && this.lettered) { this.numbered = false; } } this.symbolIndent = 0; if ((value = attributes.Remove(ElementTags.SYMBOLINDENT)) != null) { this.symbolIndent = int.Parse(value); } if ((value = attributes.Remove(ElementTags.FIRST)) != null) { char khar = value[0]; if (char.IsLetter(khar)) { setFirst(khar); } else { setFirst((char)int.Parse(value)); } } if ((value = attributes.Remove(ElementTags.INDENTATIONLEFT)) != null) { this.indentationLeft = float.Parse(value); } if ((value = attributes.Remove(ElementTags.INDENTATIONRIGHT)) != null) { this.IndentationRight = float.Parse(value); } if (attributes.Count > 0) { this.markupAttributes = attributes; } }
/// <summary> /// Replaces the attributes that are equal to null with /// the attributes of a given font. /// </summary> /// <param name="font">the font of a bigger element class</param> /// <returns>a Font</returns> public Font difference(Font font) { // size float dSize = font.size; if (dSize == UNDEFINED) { dSize = this.size; } // style int dStyle = UNDEFINED; int style1 = this.Style; int style2 = font.Style; if (style1 != UNDEFINED || style2 != UNDEFINED) { if (style1 == UNDEFINED) { style1 = 0; } if (style2 == UNDEFINED) { style2 = 0; } dStyle = style1 | style2; } // color object dColor = (Color)font.Color; if (dColor == null) { dColor = this.Color; } // family if (font.baseFont != null) { return(new Font(font.BaseFont, dSize, dStyle, (Color)dColor)); } if (font.Family != UNDEFINED) { return(new Font(font.Family, dSize, dStyle, (Color)dColor)); } if (this.baseFont != null) { if (dStyle == style1) { return(new Font(this.BaseFont, dSize, dStyle, (Color)dColor)); } else { return(FontFactory.getFont(this.Familyname, dSize, dStyle, (Color)dColor)); } } return(new Font(this.Family, dSize, dStyle, (Color)dColor)); }
/// <summary> /// Returns a Chunk that has been constructed taking in account /// the value of some attributes. /// </summary> /// <param name="attributes">some attributes</param> public Chunk(Properties attributes) : this("", FontFactory.getFont(attributes)) { string value; if ((value = attributes.Remove(ElementTags.ITEXT)) != null) { append(value); } if ((value = attributes.Remove(ElementTags.LOCALGOTO)) != null) { setLocalGoto(value); } if ((value = attributes.Remove(ElementTags.REMOTEGOTO)) != null) { String destination = attributes.Remove(ElementTags.DESTINATION); String page = attributes.Remove(ElementTags.PAGE); if (page != null) { setRemoteGoto(value, int.Parse(page)); } else if (destination != null) { setRemoteGoto(value, destination); } } if ((value = attributes.Remove(ElementTags.LOCALDESTINATION)) != null) { setLocalDestination(value); } if ((value = attributes.Remove(ElementTags.SUBSUPSCRIPT)) != null) { setTextRise(float.Parse(value)); } if ((value = attributes.Remove(MarkupTags.CSS_VERTICALALIGN)) != null && value.EndsWith("%")) { float p = float.Parse(value.Substring(0, value.Length - 1)) / 100f; setTextRise(p * font.Size); } if ((value = attributes.Remove(ElementTags.GENERICTAG)) != null) { setGenericTag(value); } if ((value = attributes.Remove(ElementTags.BACKGROUNDCOLOR)) != null) { setBackground(MarkupParser.decodeColor(value)); } if (attributes.Count > 0) { this.MarkupAttributes = attributes; } }
/// <summary> /// Returns a Paragraph that has been constructed taking in account /// the value of some attributes. /// </summary> /// <param name="attributes">Some attributes</param> public Paragraph(Properties attributes) : this("", FontFactory.getFont(attributes)) { string value; if ((value = attributes.Remove(ElementTags.ITEXT)) != null) { Chunk chunk = new Chunk(value); if ((value = attributes.Remove(ElementTags.GENERICTAG)) != null) { chunk.setGenericTag(value); } Add(chunk); } if ((value = attributes.Remove(ElementTags.ALIGN)) != null) { setAlignment(value); } if ((value = attributes.Remove(ElementTags.LEADING)) != null) { this.Leading = float.Parse(value); } else if ((value = attributes.Remove(MarkupTags.CSS_LINEHEIGHT)) != null) { this.Leading = MarkupParser.parseLength(value); } else { this.Leading = 16; } if ((value = attributes.Remove(ElementTags.INDENTATIONLEFT)) != null) { this.IndentationLeft = float.Parse(value); } if ((value = attributes.Remove(ElementTags.INDENTATIONRIGHT)) != null) { IndentationRight = float.Parse(value); } if ((value = attributes.Remove(ElementTags.KEEPTOGETHER)) != null) { keeptogether = bool.Parse(value); } if (attributes.Count > 0) { MarkupAttributes = attributes; } }