Hi there,
Thanks for your inquiry.
fmr patel:
*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();*
In your case, there is no need to use the above code.
fmr patel:
*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*
The code shared in CodeSample.docx is correct. As you are extracting the RTF text from a Paragraph and insert back RTF document to same paragraph. In this case, the code in CodeSample.docx is correct.
Regarding formatting issue, if you extract the RTF contents manually from input document and save it as RTF document, you will get the same output. Please check the rtfDocs.zip from here:
https://forum.aspose.com/t/51234
fmr patel:
Table borders are not displayed. See the original doc.
You can set the table’s border by using Table.SetBorder method and CellFormat.Borders.Top/Left/Bottom/Right properties. Please check the following code snippet for your kind reference.
Document rtfDoc = RtfStringToDocument(rtfText.Trim());
foreach (Table table in rtfDoc.GetChildNodes(NodeType.Table, true))
{
table.ClearBorders();
// Set a green border around the table but not inside.
table.SetBorder(BorderType.Left, LineStyle.Single, 1.5, Color.Green, true);
table.SetBorder(BorderType.Right, LineStyle.Single, 1.5, Color.Green, true);
table.SetBorder(BorderType.Top, LineStyle.Single, 1.5, Color.Green, true);
table.SetBorder(BorderType.Bottom, LineStyle.Single, 1.5, Color.Green, true);
foreach (Cell cell in table.GetChildNodes(NodeType.Cell, true))
{
cell.CellFormat.Borders.Top.LineStyle = LineStyle.Single;
}
}