LINK Extract Embedded Image Object in RTFI have the code below same as the link i provided it works well in 97-2003 document and same code is not working now in office 2007/2010. We usually check the RTFs with OLE object in it and Reject our conversion as per company rules but our code rejects even if there is a text written as "object" in office-2007/2010 created RTFs. Is there any solution to identify in Office-2007 created RTFs ?
using (StreamReader sr = new StreamReader(filePath))
{
RtfReader reader = new RtfReader(sr);
IEnumerator<RtfObject> enumerator = reader.Read().GetEnumerator();
while (enumerator.MoveNext())
{
if (enumerator.Current.Text == "object")
{
hasOLEObjects = true;
break;
}
}
}
public RtfReader(TextReader reader)
{
if (reader == null)
throw new ArgumentNullException("reader");
Reader = reader;
}
public class RtfObject
{
public RtfObject(string text)
{
if (text == null)
throw new ArgumentNullException("text");
Text = text.Trim();
}
public string Text { get; private set; }
}