protected string ExtractTokenList(LinkedList <Token> tokList) { LinkedListNode <Token> node; var result = new StringBuilder(); node = tokList.First; while (node != null) { if (node.Value.isControl) { result.Append(node.Value.text); } else { result.Append(RtfUtility.UnicodeEncode(node.Value.text)); } node = node.Next; } return(result.ToString()); }
public override string Render() { var rtf = new StringBuilder(); // --------------------------------------------------- // Prologue // --------------------------------------------------- rtf.AppendLine(@"{\rtf1\ansi\deff0"); rtf.AppendLine(); // --------------------------------------------------- // Insert font table // --------------------------------------------------- rtf.AppendLine(@"{\fonttbl"); for (var i = 0; i < _fontTable.Count; i++) { rtf.AppendLine(@"{\f" + i + " " + RtfUtility.UnicodeEncode(_fontTable[i]) + ";}"); } rtf.AppendLine("}"); rtf.AppendLine(); // --------------------------------------------------- // Insert color table // --------------------------------------------------- rtf.AppendLine(@"{\colortbl"); rtf.AppendLine(";"); for (var i = 1; i < _colorTable.Count; i++) { var c = _colorTable[i]; rtf.AppendLine(@"\red" + c.Red + @"\green" + c.Green + @"\blue" + c.Blue + ";"); } rtf.AppendLine("}"); rtf.AppendLine(); // --------------------------------------------------- // Preliminary // --------------------------------------------------- rtf.AppendLine(@"\deflang" + (int)_lcid + @"\plain\fs" + RtfUtility.Pt2HalfPt(DefaultValue.FontSize) + @"\widowctrl\hyphauto\ftnbj"); // page size rtf.AppendLine(@"\paperw" + RtfUtility.PaperWidthInTwip(_paper, _orientation) + @"\paperh" + RtfUtility.PaperHeightInTwip(_paper, _orientation)); // page margin rtf.AppendLine(@"\margt" + RtfUtility.Pt2Twip(Margins[Direction.Top])); rtf.AppendLine(@"\margr" + RtfUtility.Pt2Twip(Margins[Direction.Right])); rtf.AppendLine(@"\margb" + RtfUtility.Pt2Twip(Margins[Direction.Bottom])); rtf.AppendLine(@"\margl" + RtfUtility.Pt2Twip(Margins[Direction.Left])); // orientation if (_orientation == PaperOrientation.Landscape) { rtf.AppendLine(@"\landscape"); } // header/footer if (_header != null) { rtf.Append(_header.Render()); } if (_footer != null) { rtf.Append(_footer.Render()); } rtf.AppendLine(); // --------------------------------------------------- // Document body // --------------------------------------------------- rtf.Append(base.Render()); // --------------------------------------------------- // Ending // --------------------------------------------------- rtf.AppendLine("}"); return(rtf.ToString()); }