public void Write(RTFWriter writer) { writer.WriteStartGroup( ); writer.WriteKeyword("info"); foreach (string strKey in myInfo.Keys) { writer.WriteStartGroup(); if (strKey == "edmins" || strKey == "vern" || strKey == "nofpages" || strKey == "nofwords" || strKey == "nofchars" || strKey == "nofcharsws" || strKey == "id") { writer.WriteKeyword(strKey + myInfo[strKey]); } else { writer.WriteKeyword(strKey); writer.WriteText(myInfo[strKey]); } writer.WriteEndGroup(); } writer.WriteStartGroup(); WriteTime(writer, "creatim", dtmCreatim); WriteTime(writer, "revtim", dtmRevtim); WriteTime(writer, "printim", dtmPrintim); WriteTime(writer, "buptim", dtmBuptim); writer.WriteEndGroup(); }
/// <summary> /// 输出颜色表 /// </summary> /// <param name="writer">RTF文档书写器</param> public void Write(RTFWriter writer) { writer.WriteStartGroup(); writer.WriteKeyword(RTFConsts._colortbl); writer.WriteRaw(";"); for (int iCount = 0; iCount < myItems.Count; iCount++) { System.Drawing.Color c = (System.Drawing.Color)myItems[iCount]; writer.WriteKeyword("red" + c.R); writer.WriteKeyword("green" + c.G); writer.WriteKeyword("blue" + c.B); writer.WriteRaw(";"); } writer.WriteEndGroup(); }
/// <summary> /// Write font table rtf /// </summary> /// <param name="writer">rtf text writer</param> public void Write(RTFWriter writer) { writer.WriteStartGroup(); writer.WriteKeyword(RTFConsts._fonttbl); foreach (RTFFont item in this) { writer.WriteStartGroup(); writer.WriteKeyword("f" + item.Index); if (item.Charset != 0) { writer.WriteKeyword("fcharset" + item.Charset); } writer.WriteText(item.Name); writer.WriteEndGroup(); } writer.WriteEndGroup(); }
private void WriteTime(RTFWriter writer, string name, DateTime Value) { writer.WriteStartGroup(); writer.WriteKeyword(name); writer.WriteKeyword("yr" + Value.Year); writer.WriteKeyword("mo" + Value.Month); writer.WriteKeyword("dy" + Value.Day); writer.WriteKeyword("hr" + Value.Hour); writer.WriteKeyword("min" + Value.Minute); writer.WriteKeyword("sec" + Value.Second); writer.WriteEndGroup(); }
/// <summary> /// write to rtf document /// </summary> /// <param name="writer">RTF text writer</param> public virtual void Write(RTFWriter writer) { if (intType == RTFNodeType.Control || intType == RTFNodeType.Keyword || intType == RTFNodeType.ExtKeyword) { if (this.bolHasParameter) { writer.WriteKeyword( this.strKeyword + this.intParameter, this.intType == RTFNodeType.ExtKeyword); } else { writer.WriteKeyword( this.strKeyword, this.intType == RTFNodeType.ExtKeyword); } } else if (intType == RTFNodeType.Text) { writer.WriteText(this.strKeyword); } }
/// <summary> /// Test to generate a little rtf document /// </summary> /// <param name="w">RTF text writer</param> private static void TestBuildRTF(RTFWriter w) { w.Encoding = System.Text.Encoding.GetEncoding(936); // write header w.WriteStartGroup(); w.WriteKeyword("rtf1"); w.WriteKeyword("ansi"); w.WriteKeyword("ansicpg" + w.Encoding.CodePage); // wirte font table w.WriteStartGroup(); w.WriteKeyword("fonttbl"); w.WriteStartGroup(); w.WriteKeyword("f0"); w.WriteText("Arial;"); w.WriteEndGroup(); w.WriteStartGroup(); w.WriteKeyword("f1"); w.WriteText("Times New Roman;"); w.WriteEndGroup(); w.WriteEndGroup(); // write color table w.WriteStartGroup(); w.WriteKeyword("colortbl"); w.WriteText(";"); w.WriteKeyword("red0"); w.WriteKeyword("green0"); w.WriteKeyword("blue255"); w.WriteText(";"); w.WriteEndGroup(); // write content w.WriteKeyword("qc"); // set alignment center w.WriteKeyword("f0"); // set font w.WriteKeyword("fs30"); // set font size w.WriteText("This is the first paragraph text "); w.WriteKeyword("cf1"); // set text color w.WriteText("Arial "); w.WriteKeyword("cf0"); // set default color w.WriteKeyword("f1"); // set font w.WriteText("Align center ABC12345"); w.WriteKeyword("par"); // new paragraph w.WriteKeyword("pard"); // clear format w.WriteKeyword("f1"); // set font w.WriteKeyword("fs20"); // set font size w.WriteKeyword("cf1"); w.WriteText("This is the secend paragraph Arial left alignment ABC12345"); // finish w.WriteEndGroup(); }
/// <summary> /// write rtf keyword /// </summary> /// <param name="Keyword">keyword</param> public void WriteKeyword(string Keyword) { if (bolCollectionInfo == false) { myWriter.WriteKeyword(Keyword); } }