-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadWord
More file actions
29 lines (25 loc) · 698 Bytes
/
readWord
File metadata and controls
29 lines (25 loc) · 698 Bytes
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
import docx
import os
print("bins")
doc = docx.Document("testing.docx")
# doc = Document("test.docx")
blip = doc.inline_shapes[2]._inline.graphic.graphicData.pic.blipFill.blip
rID = blip.embed
document_part = doc.part
image_part = document_part.related_parts[rID]
fr = open("test1.png", "wb")
fr.write(image_part._blob)
fr.close()
print("ends")
data = ['test.png','test1.png']
i = 0
doc = docx.Document("testing.docx")
for oleEmbed in doc.inline_shapes :
blip = doc.inline_shapes[i]._inline.graphic.graphicData.pic.blipFill.blip
rID = blip.embed
document_part = doc.part
image_part = document_part.related_parts[rID]
fr = open(data[i], "wb")
fr.write(image_part._blob)
i += 1
fr.close()