SetKeepLines
Specify that when rendering this document using a page view, all lines of this paragraph are maintained on a single page whenever possible.
Parameters:
Name |
Type |
Description |
isKeepLines |
boolean
|
The true value will enable the option to keep lines of the paragraph on a single page. |
Returns:
-
This method doesn't return any data.
Example
Copy code
builder.CreateFile("docx");
oDocument = Api.GetDocument();
oMyStyle = oDocument.CreateStyle("My document style");
oParaPr = oMyStyle.GetParaPr();
oParaPr.SetKeepLines(true);
oParagraph = oDocument.GetElement(0);
oParagraph.AddText("This is an example of how the paragraph tries to keep lines together. ");
oParagraph.AddText("Scroll down to the second page to see it.");
for (x = 0; x < 5; ++x) {
oParagraph = Api.CreateParagraph();
for (i = 0; i < 10; ++i) {
oParagraph.AddText("These sentences are used to add lines for demonstrative purposes. ");
}
oDocument.Push(oParagraph);
}
oParagraph = Api.CreateParagraph();
oParagraph.AddText("The paragraph lines are moved to the next page to keep them together. ");
for (i = 0; i < 10; ++i) {
oParagraph.AddText("These sentences are used to add lines for demonstrative purposes. ");
}
oParagraph.SetStyle(oMyStyle);
oDocument.Push(oParagraph);
builder.SaveFile("docx", "SetKeepLines.docx");
builder.CloseFile();
Resulting document