Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid Page Breaks #1977

Closed
matthewrnance opened this issue Dec 1, 2020 · 1 comment
Closed

Avoid Page Breaks #1977

matthewrnance opened this issue Dec 1, 2020 · 1 comment

Comments

@matthewrnance
Copy link

I'm writing a huge document in PHPWord that includes headings followed by paragraphs of text. I want to make sure that I don't wind up with a heading at the bottom of a sheet with the corresponding text on top of the next page. Since it's a dynamic document, there's no way to know where those breaks will fall ahead of time.

In CSS, there is an "Avoid Page Break" command. Is there anything similar in PHPWord? I have searched and can't find anything. I'm hoping someone out there has discovered it or knows a work around.

something similar to this, only in php rather than css...

@media print {
  header {page-break-after: avoid;}
}
@matthewrnance
Copy link
Author

I figured it out...in case anyone else is running into the same problem, within your paragraphStyle, use the setting:

'keepNext' => true

This engages a word setting that keeps a paragraph with whatever comes immediately after it. So if the paragraph following a heading is forced onto the next page, this will make sure that the heading goes with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant