コード例 #1
0
        public static void RtfToDomTree(string rtf)
        {
            RTFDomDocument doc = new RTFDomDocument();

            doc.LoadRTFText(rtf);

            // MessageBox.Show(doc.InnerText); // convert to plain text
            MessageBox.Show(doc.ToDomString());
        }
コード例 #2
0
        private void btnLoadClipboardRTF_Click(object sender, EventArgs e)
        {
            IDataObject ido = Clipboard.GetDataObject();

            if (ido.GetDataPresent(DataFormats.Rtf))
            {
                string         rtf = ( string )ido.GetData(DataFormats.Rtf);
                RTFDomDocument doc = new RTFDomDocument();
                doc.Progress += new ProgressEventHandler(doc_Progress);
                doc.LoadRTFText(rtf);
                txtRTFDom.Text   = doc.ToDomString();
                this.Text        = "";
                myProgress.Value = 0;
            }
        }
コード例 #3
0
        public void ShouldLoadFromFile(string fileName, int length)
        {
            var file = Path.Combine(TestContext.CurrentContext.TestDirectory, "Resources", fileName + ".rtf");

            var doc = new RTFDomDocument();

            doc.Load(file);
            var text = doc.ToDomString();

            Assert.AreEqual(length, text.Length);

            doc = new RTFDomDocument();
            doc.LoadRTFText(File.ReadAllText(file));
            var rtfText = doc.ToDomString();

            Assert.AreEqual(text, rtfText);
        }