-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
55 lines (42 loc) · 1.6 KB
/
test.py
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
import docx
from docx.document import Document
doc: Document = docx.Document('cet_hec.docx')
for section in doc.sections:
print(section)
print(type(section), dir(section))
header = section.header
footer = section.footer
for paragraph in header.paragraphs:
print(paragraph.text) # or whatever you have in mind
print(footer.paragraphs)
obj = footer._document_part
print(type(obj), dir(obj))
for paragraph in footer.paragraphs:
print(paragraph)
print(paragraph.text) # or whatever you have in mind
print('first')
footer = section.first_page_footer
for paragraph in footer.paragraphs:
print(paragraph.text) # or whatever you have in mind
print('first')
header = section.first_page_header
for paragraph in header.paragraphs:
print(paragraph.text) # or whatever you have in mind
# print(paragraph.part) # or whatever you have in mind
print('even')
footer = section.even_page_footer
for paragraph in footer.paragraphs:
print('text=', paragraph.text) # or whatever you have in mind
print('even')
header = section.even_page_header
for paragraph in header.paragraphs:
print('text=', paragraph.text) # or whatever you have in mind
for table in footer.tables:
for row in table.rows:
for cell in row.cells:
print('text=', cell.text) # or whatever you have in mind
print('footer')
footer = section.footer
for paragraph in footer.paragraphs:
print(paragraph.text) # or whatever you have in mind
# print(c_doc.fields)