节对象¶
Section objects
提供对诸如边距和页面方向等部分属性的访问。
Provides access to section properties such as margins and page orientation.
|Sections|对象¶
Sections objects
|Section|对象¶
Section objects
- class docx.section.Section(sectPr: CT_SectPr, document_part: DocumentPart)[源代码]¶
Document section, providing access to section and page setup settings.
Also provides access to headers and footers.
- property bottom_margin: Length | None¶
Read/write. Bottom margin for pages in this section, in EMU.
None when no bottom margin has been specified. Assigning
Noneremoves any bottom-margin setting.
True if this section displays a distinct first-page header and footer.
Read/write. The definition of the first-page header and footer are accessed using
first_page_headerandfirst_page_footerrespectively.
_Footerobject defining footer content for even pages.The content of this footer definition is ignored unless the document setting
odd_and_even_pages_header_footeris set True.
- property even_page_header: _Header¶
_Headerobject defining header content for even pages.The content of this header definition is ignored unless the document setting
odd_and_even_pages_header_footeris set True.
_Footerobject defining footer content for the first page of this section.The content of this footer definition is ignored unless the property
different_first_page_header_footeris set True.
- property first_page_header: _Header¶
_Headerobject defining header content for the first page of this section.The content of this header definition is ignored unless the property
different_first_page_header_footeris set True.
_Footerobject representing default page footer for this section.The default footer is used for odd-numbered pages when separate odd/even footers are enabled. It is used for both odd and even-numbered pages otherwise.
Distance from bottom edge of page to bottom edge of the footer.
Read/write.
Noneif no setting is present in the XML.
- property gutter: Length | None¶
Lengthobject representing page gutter size in English Metric Units.Read/write. The page gutter is extra spacing added to the inner margin to ensure even margins after page binding. Generally only used in book-bound documents with double-sided and facing pages.
This setting applies to all pages in this section.
- header[源代码]¶
_Headerobject representing default page header for this section.The default header is used for odd-numbered pages when separate odd/even headers are enabled. It is used for both odd and even-numbered pages otherwise.
- property header_distance: Length | None¶
Distance from top edge of page to top edge of header.
Read/write.
Noneif no setting is present in the XML. AssigningNonecauses default value to be used.
- iter_inner_content() Iterator[Paragraph | Table][源代码]¶
Generate each Paragraph or Table object in this section.
Items appear in document order.
- property left_margin: Length | None¶
Lengthobject representing the left margin for all pages in this section in English Metric Units.
- property orientation: WD_ORIENTATION¶
WD_ORIENTATION member specifying page orientation for this section.
One of
WD_ORIENT.PORTRAITorWD_ORIENT.LANDSCAPE.
- property page_height: Length | None¶
Total page height used for this section.
This value is inclusive of all edge spacing values such as margins.
Page orientation is taken into account, so for example, its expected value would be
Inches(8.5)for letter-sized paper when orientation is landscape.
- property page_width: Length | None¶
Total page width used for this section.
This value is like "paper size" and includes all edge spacing values such as margins.
Page orientation is taken into account, so for example, its expected value would be
Inches(11)for letter-sized paper when orientation is landscape.
- property right_margin: Length | None¶
Lengthobject representing the right margin for all pages in this section in English Metric Units.
- property start_type: WD_SECTION_START¶
Type of page-break (if any) inserted at the start of this section.
For exmple,
WD_SECTION_START.ODD_PAGEif the section should begin on the next odd page, possibly inserting two page-breaks instead of one.