简体   繁体   中英

How to identify last Paragraph of each page in a Word document using Word Interop?

I am creating a C# program which makes some automatic changes to several Word documents. One of the requirements is to move the headings to the next page when the following paragraph is in the next page.

The image below exemplify my description:

在此处输入图片说明

At the beginning i did try to identify the headings in the Paragraphs collection (it was possible using info about the style of the headings) because I thought it will be possible to get information about its location in the current page. After some tries, I think that method will not succeed.

I think the key point of this is:

How to identify if a heading is in the last line of a page. However, I do not know if that is feasible.

I will appreciate any suggestion about how to achieve this goal.

Thanks

You don't need code to keep the heading with the paragraph text. You can achieve this setting the heading paragraph property 'keep with next'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM