Hi,
In case you would be interested...
I think I found an issue with the class Itenso.Rtf.Interpreter, method VisitTag. If I am parsing hidden text, for example an Xml style comment inserted in the middle of an Rtf document, you parser hides the text but still adds \par and \tab in the plain text output. I implemented a fix around line 291 in RtfInterpreter.cs
case RtfSpec.TagParagraph:
if(!Context.WritableCurrentTextFormat.IsHidden)
NotifyInsertBreak( RtfVisualBreakKind.Paragraph );
break;
case RtfSpec.TagLine:
NotifyInsertBreak( RtfVisualBreakKind.Line );
break;
case RtfSpec.TagPage:
NotifyInsertBreak( RtfVisualBreakKind.Page );
break;
case RtfSpec.TagTabulator:
if (!Context.WritableCurrentTextFormat.IsHidden)
NotifyInsertSpecialChar(RtfVisualSpecialCharKind.Tabulator);
break;
Sample Rtf:
{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\froman\fcharset0 Times New Roman;}{\f1\fnil Tahoma;}{\f2\fnil MS Sans Serif;}}
{\colortbl ;\red255\green0\blue0;\red0\green0\blue255;}
\viewkind4\uc1\pard\sb100\sa100\lang3084\f0\fs24 Mer 12 janvier 2011, 9h 02min 20s \par
This text should appear just before... \par
\par
\cf1\v <!--\par
\par
_filtered \{font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;\}\par
_filtered \{font-family:Tahoma;panose-1:2 11 6 4 3 5 4 4 2 4;\}\par
_filtered \{font-family:"Wingdings 2";panose-1:5 2 1 2 1 5 7 7 7 7;\}\par
\par
p.MsoNormal, li.MsoNormal, div.MsoNormal\par
\tab\{margin:0cm;margin-bottom:.0001pt;font-size:12.0pt;font-family:"serif";\}\par
a:link, span.MsoHyperlink\par
\tab\{font-family:"sans-serif";\}\par
.MsoChpDefault\par
\tab\{font-family:"sans-serif";\}\par
_filtered \{margin:72.0pt 90.0pt 72.0pt 90.0pt;\}\par
div.WordSection1\par
\tab\{\}\par
-->\cf0\v0 ...that text, without extra linefeed or spaces
}
==================
Also the Microsoft RichTextbox control renders plain text differently from your library because it adds a line break when it hits a \row tag in the Rtf source. I was able to fix this with a 'patch' since your library doesn't seem to fully implement support for \intbl and \trow . The patch is;
Class RtfSpec:
public const string TagRow = "row";
Method RtfInterpreter.VisitTag:
case RtfSpec.TagRow:
case RtfSpec.TagParagraph:
if(!Context.WritableCurrentTextFormat.IsHidden)
NotifyInsertBreak( RtfVisualBreakKind.Paragraph );
break;
...and it works fine.
Thanks.
Sylvain