Hi,
I’m struggling with an issue to create comments without carriage return or line break.
Actually, I’m using an external library to annotate comments. While exporting my html to word I convert those annotations to Aspose word comments as follow:
var cssStyleRegex = new Regex(@"<annotation.*?>(.*?)<\/annotation>");
var match = cssStyleRegex.Match(contentXHTML);
if (match.Success)
{
int commentId = 0;
int endOfIndexPrevmatch = 0;
int contentLength = contentXHTML.Length;
foreach (Match m in cssStyleRegex.Matches(contentXHTML))
{
XmlDocument doc = new XmlDocument();
doc.XmlResolver = null;
string annotationStr = m.Value;
int indexMatch = m.Index;
builder.InsertHtml(contentXHTML.Substring(endOfIndexPrevmatch, indexMatch - endOfIndexPrevmatch));
Aspose.Words.Comment comment = new Aspose.Words.Comment(builder.Document);
if (annotation.Comments.Count == 0)
{
GetTextEditionTracking(builder, node.InnerXml);
continue;
}
comment.Author = annotation.Comments[0].UserName;
comment.DateTime = annotation.Comments[0].TimeConverted;
comment.Initial = annotation.Comments[0].UserId;
comment.SetText(annotation.Comments[0].Text);
CommentRangeStart start = new commentRangeStart(builder.Document, comment.Id);
builder.InsertNode(start);
// Insert some more text.
//builder.Write(node.InnerText);
GetTextEditionTracking(builder, node.InnerXml);
// Insert end of comment range.
CommentRangeEnd end = new CommentRangeEnd(builder.Document, comment.Id);
builder.InsertNode(end);
// Insert comment and comment range start.
builder.InsertNode(comment);
......
My goal is to avoid the carriage return inserted automatically before my comments.
This is an issue for text annotated in the middle of a sentence.
I’m using Aspose Words: 20.9.0.0 for .Net.
Regards