diff --git a/docs/usage/paragraph.md b/docs/usage/paragraph.md index 65b7cc3eeb..d3b5b36547 100644 --- a/docs/usage/paragraph.md +++ b/docs/usage/paragraph.md @@ -305,4 +305,12 @@ Example: https://github.com/dolanmiu/docx/blob/master/demo/15-page-break-before. ## Page break control -Paragraphs have `.keepLines()` and `.keepNext()` methods that allow restricting page breaks within and between paragraphs. See [this Microsoft article](https://support.office.com/en-us/article/Keep-lines-and-paragraphs-together-d72af534-926f-4c4b-830a-abfc2daa3bfa) for more details) +Paragraphs have `keepLines` and `keepNext` properties that allow restricting page breaks within and between paragraphs. See [this Microsoft article](https://support.office.com/en-us/article/Keep-lines-and-paragraphs-together-d72af534-926f-4c4b-830a-abfc2daa3bfa) for more details. + +```ts +const paragraph = new Paragraph({ + text: "Stay on the same page", + keepLines: true, + keepNext: true, +}); +``` diff --git a/src/file/paragraph/properties.ts b/src/file/paragraph/properties.ts index 39e5a3d28c..a02e2a7b96 100644 --- a/src/file/paragraph/properties.ts +++ b/src/file/paragraph/properties.ts @@ -23,7 +23,13 @@ export interface ILevelParagraphStylePropertiesOptions { readonly leftTabStop?: number; readonly indent?: IIndentAttributesProperties; readonly spacing?: ISpacingProperties; + /** + * Specifies that the paragraph (or at least part of it) should be rendered on the same page as the next paragraph when possible. If multiple paragraphs are to be kept together but they exceed a page, then the set of paragraphs begin on a new page and page breaks are used thereafter as needed. + */ readonly keepNext?: boolean; + /** + * Specifies that all lines of the paragraph are to be kept on a single page when possible. + */ readonly keepLines?: boolean; readonly outlineLevel?: number; }