How to realize the following paragraph format with spire.DOC? We like to suppress the page break inside a table.
With Selection.ParagraphFormat
.KeepWithNext = True
.KeepTogether = True
End With
Thank you in advance
Document doc = new Document();
doc.LoadFromFile("..\\..\\1.docx");
foreach (Section section in doc.Sections)
{
for (int i = 0; i < section.Body.Paragraphs.Count; i++)
{
Paragraph paragraph = section.Body.Paragraphs[i];
if (HasPageBreak(paragraph))
{
section.Body.Paragraphs.Remove(paragraph);
}
}
}
string output = "result.docx";
doc.SaveToFile(output,FileFormat.Docx);
System.Diagnostics.Process.Start(output);
}
static bool HasPageBreak(Paragraph paragraph)
{
bool result = false;
for (int i = 0; i < paragraph.ChildObjects.Count; i++)
{
DocumentObject obj = paragraph.ChildObjects[i];
if (obj.DocumentObjectType == DocumentObjectType.Break)
{
if ((obj as Break).BreakType == BreakType.PageBreak)
{
result = true;
}
}
}
return result;
}