c# - Word Automation: Detect if page break is necessary? -


I am working on a project in C # which will create a Word document using Word Automation API.

I would like to insert page breaks at specific points in the generated document and I am currently doing this successfully with the following code:

  // page break object page GenerateBreak = WDbrakeType WdPageBreak; WordApp.Selection.InsertBreak (Ref PageBrack); However, if the document wraps naturally on the next page even after going out of the room on the previous page, then I really do not want to generate a page break or else I will see the blank page. Ends with.  

What I really like is the ability to find where the cursor is, and if it is on the first line and column of the current page, then I can safely assume it is to insert this page break Not necessary for

Is there a way to reach the position of the cursor? Or a solution that will do the same thing? It looks like a simple requirement, I apologize in advance if I have missed it clearly.

Assuming that you are creating the document in a program in such a way that wordApp will be. To accurately reflect your actual (and relevant) status in the document in the selection, you can set your line and column on its initial page by using its information property and the following two WdInformation enums (here the form of VBA Is not sure what the .net PIA syntax is):

  line = wordApp.Selection.Information (wdFirstCharacterLineNumber) col = wordApp.Selection.Information (wdFirstCharacterColumnNumber)  

The value of the word Tets are at times LN and consistent with Colonel values. If both of them are equal to 1, then you are in the first position of the page on which the selection begins.

Good luck!


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -