Breaks ====== Word supports a variety of breaks that interrupt the flow of text in the document: * line break * page break * column break * section break (new page, even page, odd page) In addition, a page break can be forced by formatting a paragraph with the "page break before" setting. This analysis is limited to line, page, and column breaks. A section break is implemented using a completely different set of elements and is covered separately. Candidate protocol -- run.add_break() ------------------------------------- The following interactive session demonstrates the protocol for adding a page break:: >>> run = p.add_run() >>> run.breaks [] >>> run.add_break() # by default adds WD_BREAK.LINE >>> run.breaks [] >>> run.breaks[0].type.__name__ WD_BREAK.LINE >>> run.add_break(WD_BREAK.LINE) >>> run.breaks [, ] >>> run.add_break(WD_BREAK.PAGE) >>> run.add_break(WD_BREAK.COLUMN) >>> run.add_break(WD_BREAK.LINE_CLEAR_LEFT) >>> run.add_break(WD_BREAK.LINE_CLEAR_RIGHT) >>> run.add_break(WD_BREAK.TEXT_WRAPPING) Enumeration -- WD_BREAK_TYPE ---------------------------- * WD_BREAK.LINE * WD_BREAK.LINE_CLEAR_LEFT * WD_BREAK.LINE_CLEAR_RIGHT * WD_BREAK.TEXT_WRAPPING (e.g. LINE_CLEAR_ALL) * WD_BREAK.PAGE * WD_BREAK.COLUMN * WD_BREAK.SECTION_NEXT_PAGE * WD_BREAK.SECTION_CONTINUOUS * WD_BREAK.SECTION_EVEN_PAGE * WD_BREAK.SECTION_ODD_PAGE Specimen XML ------------ .. highlight:: xml Line break ~~~~~~~~~~ This XML is produced by Word after inserting a line feed with Shift-Enter:: Text before and after line break Word loads this more straightforward generation just fine, although it changes it back on next save. I'm not sure of the advantage in creating a fresh run such that the ```` element is the first child:: Text before and after line break Page break ~~~~~~~~~~ Starting with this XML ... :: Before inserting a page break, the cursor was here } This was the following paragraph, the last in the document ... this XML is produced by Word on inserting a hard page:: Before inserting a page break, the cursor was here } This was the following paragraph, the last in the document Word loads the following simplified form fine ... :: Text before an intra-run page break Text after an intra-run page break following paragraph ... although on saving it converts it to this:: Text before an intra-run page break Text after an intra-run page break following paragraph Schema excerpt -------------- .. highlight:: xml :: Resources --------- * `WdBreakType Enumeration on MSDN`_ * `Range.InsertBreak Method (Word) on MSDN`_ .. _WdBreakType Enumeration on MSDN: http://msdn.microsoft.com/en-us/library/office/ff195905.aspx .. _Range.InsertBreak Method (Word) on MSDN: http://msdn.microsoft.com/en-us/library/office/ff835132.aspx Relevant sections in the ISO Spec ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * 17.18.3 ST_BrClear (Line Break Text Wrapping Restart Location)