Hi Tahir,
Thanks for your response. First of all the below code to remove the pargraph break is not working. The run.text is never giving the ControlChar.Cr for any of the runs…
foreach (Run run in para.Runs.ToArray())
{
if (run.Text.Contains(ControlChar.Cr))
run.Text = run.Text.Replace(ControlChar.Cr, "");
}
Also, We need to remove or comment the below line as we are already deleting the StartNode.
para.Remove();
I tested it by having the non-Rtf text before the rtf content in the same paragraph. The converted rtfDoc got inserted in the new line only. See the attached Rtf_to_WordConversion_v1.zip. I have updated the commentes in the Aspose_Output.docx. Please compare this output with the Expected_Output.doc.
eg:
- rtf text:
Testing-2:{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\fnil\fcharset0 Times New Roman;}} \viewkind4\uc1\pard\sa240\b\i\f0\fs20 The following replaces Section 11.02 of the Basic Sunday Document:\par \pard\ul\i0 Late Wednesday\ulnone . \b0 If a Tuesday continues in employment as an Employee after his Normal Wednesday Age, he shall continue to have a 100 Jan vested interest in his Mar and shall continue to participate in the Sunday until his Severance Date. A Tuesday may not elect to receive a distribution of his Mar until his severance from employment in accordance with Articles 12 and 13.\f1\par }
- Current Output:
Testing-2:
The following replaces Section 11.02 of the Basic Sunday Document:
Late Wednesday. If a Tuesday continues in employment as an Employee after his Normal Wednesday Age, he shall continue to have a 100 Jan vested interest in his Mar and shall continue to participate in the Sunday until his Severance Date. A Tuesday may not elect to receive a distribution of his Mar until his severance from employment in accordance with Articles 12 and 13.
- Expected Output:
Testing-2:The following replaces Section 11.02 of the Basic Sunday Document:
Late Wednesday. If a Tuesday continues in employment as an Employee after his Normal Wednesday Age, he shall continue to have a 100 Jan vested interest in his Mar and shall continue to participate in the Sunday until his Severance Date. A Tuesday may not elect to receive a distribution of his Mar until his severance from employment in accordance with Articles 12 and 13.
I was expecting that the suggested solution with removing the paragraph break will insert the converted rtfDoc exactly at the start of “{\rtf1” text after “Testing-2:”, But it didn’t.
I am able to resolve the above issue by using the code highlighted in yellow in CodeSample.docx.
Let me know, If you have any other alternative solution to handle the scenarios explained above.
However, I am still having the formatting issues mentioned in the comments in the Aspose_Ouput.doc