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; }
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, 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; }
public static void Main(String[] args) { Properties properties = new Properties(); properties.Load(new FileStream("c:/home/blowagie/key.properties", FileMode.Open)); String path = properties["PRIVATE"]; char[] pass = properties["PASSWORD"].ToCharArray(); Pkcs12Store ks = new Pkcs12Store(); ks.Load(new FileStream(path, FileMode.Open), pass); String alias = ""; foreach (string al in ks.Aliases) { if (ks.IsKeyEntry(al) && ks.GetKey(al).Key.IsPrivate) { alias = al; break; } } AsymmetricKeyParameter pk = ks.GetKey(alias).Key; ICollection<X509Certificate> chain = new List<X509Certificate>(); foreach (X509CertificateEntry entry in ks.GetCertificateChain(alias)) { chain.Add(entry.Certificate); } IOcspClient ocspClient = new OcspClientBouncyCastle(); C3_01_SignWithCAcert.Sign(DEST, chain, pk, DigestAlgorithms.SHA256, CryptoStandard.CMS, "Test", "Ghent", null, ocspClient, null, 0); }
public void AddAll(Properties col) { foreach (string itm in col.Keys) { _col[itm] = col[itm]; } }
/** * 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, 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); } } }
public static Section GetSection(Section parent, Properties attributes) { Section section = parent.AddSection(""); SetSectionParameters(section, attributes); return section; }
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, System.Globalization.NumberFormatInfo.InvariantInfo); } value = attributes[ElementTags.INDENTATIONRIGHT]; if (value != null) { paragraph.IndentationRight = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo); } return paragraph; }
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, 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; }
// 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, 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); } }
/// <summary> /// Creates a given Section following a set of attributes and adds it to this one. /// </summary> /// <param name="attributes">the attributes</param> /// <returns>the newly added Section</returns> public virtual Section AddSection(Properties attributes) { Section section = new Section(new Paragraph(""), 1); string value; if ((value = attributes.Remove(ElementTags.NUMBER)) != null) { subsections = int.Parse(value) - 1; } if ((value = attributes.Remove(ElementTags.BOOKMARKOPEN)) != null) { this.BookmarkOpen = bool.Parse(value); } section.Set(attributes); Add(section); return section; }
/// <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 GetInstance(Properties attributes) { string value = attributes.Remove(ElementTags.URL); if (value == null) throw new Exception("The URL of the image is missing."); Image image = Image.GetInstance(value); int align = Element.ALIGN_LEFT; if ((value = attributes.Remove(ElementTags.ALIGN)) != null) { if (ElementTags.ALIGN_LEFT.ToLower().Equals(value)) align |= Image.LEFT_ALIGN; else if (ElementTags.ALIGN_RIGHT.ToLower().Equals(value)) align |= Image.RIGHT_ALIGN; else if (ElementTags.ALIGN_MIDDLE.ToLower().Equals(value)) align |= Image.MIDDLE_ALIGN; } if ((value = attributes.Remove(ElementTags.UNDERLYING)) != null) { if (bool.Parse(value)) align |= Image.UNDERLYING; } if ((value = attributes.Remove(ElementTags.TEXTWRAP)) != null) { if (bool.Parse(value)) align |= Image.TEXTWRAP; } image.alignment = align; if ((value = attributes.Remove(ElementTags.ALT)) != null) { image.Alt = value; } string x; string y; if (((x = attributes.Remove(ElementTags.ABSOLUTEX)) != null) && ((y = attributes.Remove(ElementTags.ABSOLUTEY)) != null)) { image.SetAbsolutePosition(float.Parse(x), float.Parse(y, System.Globalization.NumberFormatInfo.InvariantInfo)); } if ((value = attributes.Remove(ElementTags.PLAINWIDTH)) != null) { image.ScaleAbsoluteWidth(float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo)); } if ((value = attributes.Remove(ElementTags.PLAINHEIGHT)) != null) { image.ScaleAbsoluteHeight(float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo)); } if ((value = attributes.Remove(ElementTags.ROTATION)) != null) { image.Rotation = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo); } return image; }
/// <summary> /// Creates a new Chapter following a set of attributes. /// </summary> /// <param name="attributes">the attributes</param> /// <param name="number">the Chapter number</param> /// <overoads> /// Has three overloads. /// </overoads> public Chapter(Properties attributes, int number) : this(new Paragraph(""), number) { string value; if ((value = attributes.Remove(ElementTags.NUMBERDEPTH)) != null) { this.NumberDepth = int.Parse(value); } if ((value = attributes.Remove(ElementTags.INDENT)) != null) { this.Indentation = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo); } if ((value = attributes.Remove(ElementTags.INDENTATIONLEFT)) != null) { this.IndentationLeft = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo); } if ((value = attributes.Remove(ElementTags.INDENTATIONRIGHT)) != null) { this.IndentationRight = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo); } if ((value = attributes.Remove(ElementTags.BOOKMARKOPEN)) != null) { this.BookmarkOpen = bool.Parse(value); } }
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; } }
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; } }
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; }
public static ChapterAutoNumber GetChapter(Properties attributes) { ChapterAutoNumber chapter = new ChapterAutoNumber(""); SetSectionParameters(chapter, attributes); return chapter; }
/// <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, 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; }
private static void LoadRegistry() { Stream isp = GetResourceStream(RESOURCE_PATH_CMAP + "cjk_registry.properties"); Properties p = new Properties(); p.Load(isp); isp.Close(); foreach (string key in p.Keys) { String value = p[key]; String[] sp = value.Split(cspace, StringSplitOptions.RemoveEmptyEntries); Dictionary<String,object> hs = new Dictionary<string,object>(); foreach (String s in sp) { hs[s] = null; } registryNames[key] = hs; } }
public static ListItem GetListItem(Properties attributes) { ListItem item = new ListItem(GetParagraph(attributes)); return item; }
internal static Dictionary<String, Object> ReadFontProperties(String name) { name += ".properties"; Stream isp = GetResourceStream(RESOURCE_PATH_CMAP + 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"); Dictionary<String, Object> map = new Dictionary<string,object>(); foreach (string key in p.Keys) { map[key] = p[key]; } map["W"] = W; map["W2"] = W2; return map; }
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, 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; }
/** * 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)myTags).IsHtml(name)) { // we do nothing return; } if (((HtmlTagMap)myTags).IsHead(name)) { // we do nothing return; } if (((HtmlTagMap)myTags).IsTitle(name)) { // we do nothing return; } if (((HtmlTagMap)myTags).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)myTags).IsLink(name)) { // we do nothing for the moment, in a later version we could extract the style sheet return; } if (((HtmlTagMap)myTags).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 (Table.IsTag(peer.Tag) || Cell.IsTag(peer.Tag)) { Properties p = peer.GetAttributes(attrs); String value; if (Table.IsTag(peer.Tag) && (value = p[ElementTags.BORDERWIDTH]) != null) { if (float.Parse(value, System.Globalization.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); }
/** * 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, 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; }
/** * @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; }
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, 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); } }
/// <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; }
/** * 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, 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); }
/// <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; }
public static void Register(Properties attributes) { string path; string alias = null; path = attributes.Remove("path"); alias = attributes.Remove("alias"); fontImp.Register(path, alias); }
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, 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; }