//[System.STAThread]
        //static void Main()
        //{
        //    TestWriteFile();
        //    TestClipboard();
        //}

        /// <summary>
        /// 测试生成RTF文件
        /// 执行这个函数后可以使用 MS Word 打开文件 c:\a.rtf
        /// </summary>
        internal static void TestWriteFile()
        {
            RTFWriter w = new RTFWriter("c:\\a.rtf");

            TestBuildRTF(w);
            w.Close();
            System.Windows.Forms.MessageBox.Show("好了,你可以打开文件 c:\\a.rtf 了.");
        }
        /// <summary>
        /// 测试生成RTF文档并设置到系统剪切板中
        /// 执行这个函数后就可以在 MS Word中使用粘贴操作来显示程序生成的文档了
        /// </summary>
        internal static void TestClipboard()
        {
            System.IO.StringWriter myStr = new System.IO.StringWriter();
            RTFWriter w = new RTFWriter(myStr);

            TestBuildRTF(w);
            w.Close();
            System.Windows.Forms.DataObject data = new System.Windows.Forms.DataObject();
            data.SetData(System.Windows.Forms.DataFormats.Rtf, myStr.ToString());
            System.Windows.Forms.Clipboard.SetDataObject(data, true);
            System.Windows.Forms.MessageBox.Show("好了,你可以在MS Word 中粘贴文本了.");
        }
 /// <summary>
 /// 测试生成RTF文档
 /// </summary>
 /// <param name="w">RTF文档书写器</param>
 public static void TestBuildRTF(RTFWriter w)
 {
     w.Encoding = System.Text.Encoding.GetEncoding(936);
     // 输出文件头
     w.WriteStartGroup();
     w.WriteKeyword("rtf1");
     w.WriteKeyword("ansi");
     w.WriteKeyword("ansicpg" + w.Encoding.CodePage);
     // 输出字体表
     w.WriteStartGroup();
     w.WriteKeyword("fonttbl");
     w.WriteStartGroup();
     w.WriteKeyword("f0");
     w.WriteText("隶书;");
     w.WriteEndGroup();
     w.WriteStartGroup();
     w.WriteKeyword("f1");
     w.WriteText("宋体;");
     w.WriteEndGroup();
     w.WriteEndGroup();
     // 输出颜色表
     w.WriteStartGroup();
     w.WriteKeyword("colortbl");
     w.WriteText(";");
     w.WriteKeyword("red0");
     w.WriteKeyword("green0");
     w.WriteKeyword("blue255");
     w.WriteText(";");
     w.WriteEndGroup();
     // 输出正文
     w.WriteKeyword("qc");    // 设置居中对齐
     w.WriteKeyword("f0");    // 设置字体
     w.WriteKeyword("fs30");  // 字体大小
     w.WriteText("这是第一段文本 ");
     w.WriteKeyword("cf1");   // 设置颜色
     w.WriteText("隶书 ");
     w.WriteKeyword("cf0");   // 设置为默认颜色
     w.WriteKeyword("f1");    // 设置字体
     w.WriteText("居中对齐 ABC12345");
     w.WriteKeyword("par");   // 开始新的段落
     w.WriteKeyword("pard");  // 清除居中对齐
     w.WriteKeyword("f1");    // 设置字体
     w.WriteKeyword("fs20");  // 字体大小
     w.WriteKeyword("cf1");
     w.WriteText("这是第二段文本 宋体 左对齐 ABC12345");
     // 结束输出
     w.WriteEndGroup();
 }