forked from python-openxml/python-docx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsection.py
More file actions
159 lines (133 loc) · 4.52 KB
/
section.py
File metadata and controls
159 lines (133 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# encoding: utf-8
"""
The |Section| object and related proxy classes.
"""
from __future__ import absolute_import, print_function, unicode_literals
class Section(object):
"""
Document section, providing access to section and page setup settings.
"""
def __init__(self, sectPr):
super(Section, self).__init__()
self._sectPr = sectPr
@property
def bottom_margin(self):
"""
|Length| object representing the bottom margin for all pages in this
section in English Metric Units.
"""
return self._sectPr.bottom_margin
@bottom_margin.setter
def bottom_margin(self, value):
self._sectPr.bottom_margin = value
@property
def footer_distance(self):
"""
|Length| object representing the distance from the bottom edge of the
page to the bottom edge of the footer. |None| if no setting is present
in the XML.
"""
return self._sectPr.footer
@footer_distance.setter
def footer_distance(self, value):
self._sectPr.footer = value
@property
def gutter(self):
"""
|Length| object representing the page gutter size in English Metric
Units for all pages in this section. The page gutter is extra spacing
added to the *inner* margin to ensure even margins after page
binding.
"""
return self._sectPr.gutter
@gutter.setter
def gutter(self, value):
self._sectPr.gutter = value
@property
def header_distance(self):
"""
|Length| object representing the distance from the top edge of the
page to the top edge of the header. |None| if no setting is present
in the XML.
"""
return self._sectPr.header
@header_distance.setter
def header_distance(self, value):
self._sectPr.header = value
@property
def left_margin(self):
"""
|Length| object representing the left margin for all pages in this
section in English Metric Units.
"""
return self._sectPr.left_margin
@left_margin.setter
def left_margin(self, value):
self._sectPr.left_margin = value
@property
def orientation(self):
"""
Member of the :ref:`WdOrientation` enumeration specifying the page
orientation for this section, one of ``WD_ORIENT.PORTRAIT`` or
``WD_ORIENT.LANDSCAPE``.
"""
return self._sectPr.orientation
@orientation.setter
def orientation(self, value):
self._sectPr.orientation = value
@property
def page_height(self):
"""
Total page height used for this section, 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.
"""
return self._sectPr.page_height
@page_height.setter
def page_height(self, value):
self._sectPr.page_height = value
@property
def page_width(self):
"""
Total page width used for this section, inclusive of 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.
"""
return self._sectPr.page_width
@page_width.setter
def page_width(self, value):
self._sectPr.page_width = value
@property
def right_margin(self):
"""
|Length| object representing the right margin for all pages in this
section in English Metric Units.
"""
return self._sectPr.right_margin
@right_margin.setter
def right_margin(self, value):
self._sectPr.right_margin = value
@property
def start_type(self):
"""
The member of the :ref:`WdSectionStart` enumeration corresponding to
the initial break behavior of this section, e.g.
``WD_SECTION.ODD_PAGE`` if the section should begin on the next odd
page.
"""
return self._sectPr.start_type
@start_type.setter
def start_type(self, value):
self._sectPr.start_type = value
@property
def top_margin(self):
"""
|Length| object representing the top margin for all pages in this
section in English Metric Units.
"""
return self._sectPr.top_margin
@top_margin.setter
def top_margin(self, value):
self._sectPr.top_margin = value