In an existing document i would like to go through all the page breaks and insert a new line before the pagebreak and after pagebrake. Please see the screenshot of what i would like to achieve
Can you please help me with that.
In an existing document i would like to go through all the page breaks and insert a new line before the pagebreak and after pagebrake. Please see the screenshot of what i would like to achieve
Can you please help me with that.
@cyrusdaru1 You can easily achieve this using find and replace functionality. You can use &m metacharacter to match manual page break and &p for paragraph break. Please see Range.Replace for more information.
In your case code should look like this:
Document doc = new Document(@"C:\Temp\in.docx");
doc.Range.Replace("&m", "&p&m&p");
doc.Save(@"C:\Temp\out.docx");
Hi , how can i check before replacing that if &p exists before &m then do not replace and similary if &p exists after &m do not replace only replace when &p before or after &m does not exists
@cyrusdaru1 I think the easiest way to achieve what you need to replace sequence of two &p before and after &m with one paragraph break after running the doc.Range.Replace("&m", "&p&m&p").