Exemple #1
0
        public override string Parse()
        {
            RTFDomDocument doc = new RTFDomDocument();

            doc.Load(this.Context.Path);
            return(doc.InnerText);
        }
Exemple #2
0
        static Stream BRtfImage(byte[] byteArray)
        {
            MemoryStream msrtf = new MemoryStream(byteArray);
            MemoryStream msout = null;

            /*
             * var document = new Spire.Doc.Document();
             * //document.LoadFromFile(@"test-doc.rtf");
             * ms.Seek(0, SeekOrigin.Begin);
             * document.LoadRtf(ms, Encoding.UTF8);
             * document.SaveToStream(msout, FileFormat.Docx2010);
             * msout.Seek(0, SeekOrigin.Begin);
             * //StreamReader reader = new StreamReader(msout);
             * //string text = reader.ReadToEnd();
             */
            var rtf = new RTFDomDocument();

            rtf.Load(msrtf);
            var elems = rtf.Elements;
            var el    = FindImage(elems);

            if (el != null)
            {
                var image = (RTFDomImage)el;
                image.DesiredWidth = 200;
                msout = new MemoryStream(image.Data);
            }
            return(msout);
        }
Exemple #3
0
 /// <summary>
 /// 从指定的文本读取器中加载RTF文档
 /// </summary>
 /// <param name="reader">文本读取器</param>
 /// <returns>操作是否成功</returns>
 public virtual bool Load(System.IO.TextReader reader)
 {
     _RTFDocument.Load(reader);
     _RTFDocument.FixForParagraphs(_RTFDocument);
     //format.Reset();
     //CurrentParagraphEOF = null;
     return(true);
 }
Exemple #4
0
 public void TestFiles()
 {
     foreach (var file in Assembly.GetExecutingAssembly().GetManifestResourceNames().Where(r => r.Contains("TestData") && r.EndsWith(".rtf")))
     {
         var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(file);
         var document = new RTFDomDocument();
         document.Load(stream);
     }
 }
Exemple #5
0
 public override string Parse()
 {
     RTFDomDocument doc = new RTFDomDocument();
     doc.Load(this.Context.Path);
     if (doc.HtmlContent == null)
         return doc.InnerText;
     else
         return doc.HtmlContent;
 }
Exemple #6
0
        public override string Parse()
        {
            RTFDomDocument doc = new RTFDomDocument();

            doc.Load(this.Context.Path);
            if (doc.HtmlContent == null)
            {
                return(doc.InnerText);
            }
            else
            {
                return(doc.HtmlContent);
            }
        }
Exemple #7
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);
        }
Exemple #8
0
 public override string Parse()
 {
     RTFDomDocument doc = new RTFDomDocument();
     doc.Load(this.Context.Path);
     return doc.InnerText;
 }