问题
I've added a Field 'Page' to my code using code:
def _add_field(run, field):
""" add a field to a run
"""
fldChar1 = OxmlElement('w:fldChar') # creates a new element
fldChar1.set(qn('w:fldCharType'), 'begin') # sets attribute on element
instrText = OxmlElement('w:instrText')
instrText.set(qn('xml:space'), 'preserve') # sets attribute on element
instrText.text = field
fldChar2 = OxmlElement('w:fldChar')
fldChar2.set(qn('w:fldCharType'), 'separate')
t = OxmlElement('w:t')
t.text = "Right-click to update field."
fldChar2.append(t)
fldChar4 = OxmlElement('w:fldChar')
fldChar4.set(qn('w:fldCharType'), 'end')
r_element = run._r
r_element.append(fldChar1)
r_element.append(instrText)
r_element.append(fldChar2)
r_element.append(fldChar4)
def _add_number_range(run, name):
""" add a number range field to a run
"""
_add_field(run, r'SEQ %s \* ARABIC' % name)
Now as section is on page-3 of the document its getting number 3 and further pages get the page number as 4,5,...
How to reset this starting page number for that section as 1 from 3 using python-docx?
Here is the image of doing it from MSWord: Solution from MSWord
来源:https://stackoverflow.com/questions/57181035/how-to-reset-page-number-to-1-in-python-docx