Hello,
I am using "<p style='page-break-after: always;'></p> " this line from database to add a page break in word file. It was working before. but currently it is not working.
Looking for your help.
Document document = new Document();
Section section=document.AddSection();
section.AddParagraph().AppendText("hello world");
//section.AddParagraph().AppendHTML("<p style='page-break-after: always;'></p> ");
section.AddParagraph().AppendBreak(BreakType.PageBreak);
section.AddParagraph().AppendText("hello world sec page");
document.SaveToFile("result.docx",FileFormat.Docx); Document document = new Document();
string finalstring = "TEST 1 <pd4ml:page.break> TEST 2";
string strHTMLContent = finalstring.Replace("<pd4ml:page.break>", "$placeholder-page-break");
Paragraph paragraph = document.AddSection().AddParagraph();
paragraph.AppendHTML(strHTMLContent);
//find the placeholder key
TextSelection[] textSelections = document.FindAllString("$placeholder-page-break", false,true);
foreach(TextSelection selection in textSelections)
{
TextRange range = selection.GetAsOneRange();
Paragraph ownerParagraph = range.OwnerParagraph;
int index=ownerParagraph.ChildObjects.IndexOf(range);
//insert a pagebreak into the position of the placeholder
ownerParagraph.ChildObjects.Insert(index,new Break(document, BreakType.PageBreak));
//remove the placeholder
ownerParagraph.ChildObjects.Remove(range);
}
document.SaveToFile("output.docx",FileFormat.Docx);