Mon Sep 01, 2014 10:19 am
I try to load html file , do the page breaks and and save it after to docx.
Here is the code :
Document document = new Document();
document.LoadFromFile(filename, FileFormat.Html, XHTMLValidationType.None);
//add page break
TextSelection[] selections = document.FindAllString("SAUTDEPAGE", false, true);
if (selections != null)
{
foreach (TextSelection ts in selections)
{
TextRange range = ts.GetAsOneRange();
Paragraph paragraph = range.OwnerParagraph;
int index = paragraph.ChildObjects.IndexOf(range);
Break stun = new Break(document, BreakType.PageBreak);
paragraph.ChildObjects.Insert(++index, stun);
}
document.Replace("SAUTDEPAGE", string.Empty, true, true);
}
//save file
SaveDocument(destfilename, document, FileFormat.Docx);
When the file saved, i open it and i have not the pagebreak instead of SAUTDEPAGE bookmark.
The html file is attached.
Thank you.
Login to view the files attached to this post.