/// <summary> /// Appends the definition of single table row /// </summary> /// <param name="node">Where to append the rtf elemenets (consider this as output)</param> /// <param name="cells">the definitions of the cells</param> public static void AddTableRow(this RtfTreeNode node, TextCell[] cells) { node.AddKeyword("trowd"); node.AddKeyword("trgaph", 400); int borderOffset = 0; foreach (var cell in cells) { borderOffset += cell.Width; node.AddSingleBorder(cell.BorderWidth); node.AddKeyword("cellx", borderOffset); } foreach (var cell in cells) { node.AddKeyword("pard"); switch (cell.TextAlignement) { case TextAlignement.Centered: node.AddCommand("qc"); break; case TextAlignement.Left: node.AddCommand("ql"); break; default: throw new NotSupportedException("Unexpected alignment"); } var grp = new RtfTreeNode(RtfNodeType.Group); if (cell.IsBold) { grp.AddCommand("b"); } node.AddKeyword("intbl"); grp.AddText(cell.Text); node.AppendChild(grp); node.AddKeyword("cell"); } node.AddKeyword("row"); }