How to replace an empty row and section breaks

  1. I 'd like to replace the section break in a document with a page break(in the word is ^b,^m)

  2. I want to remove blank lines, I found an empty row is \r,I have document, paragraph.range.text="Text row\r\r"; I want to get a result:range.text="Text row\r",doca.Range.Replace(new Regex(@"\r\r"), "");doca.Range.Replace(new Regex(@"\r\r"), ""),this is not success

Hi,

Thanks for your inquiry.

  1. Please use the code suggested in the following thread to replace section breaks with page breaks:
    https://forum.aspose.com/t/99800

  2. To remove blank lines, please try using the following code snippet:

Node[] paras = doc.GetChildNodes(NodeType.Paragraph, true).ToArray();
foreach(Paragraph p in paras)
if (string.IsNullOrEmpty(p.ToString(SaveFormat.Text).Trim()))
    p.Remove();

I hope, this helps.

Best Regards,

that work is ok, but
if paragraph has Aspose.Words.Drawing.DrawingML, also delete Aspose.Words.Drawing.DrawingML

Hi,

Thanks for your inquiry. I think, you should just use Aspose.Words.CompositeNode.RemoveAllChildren Method to remove all children of Paragraph node. I hope, this helps.

Best Regards,