python-docx2txt
python-docx2txt copied to clipboard
Image Paths in generated Text
Is there any way where we can get stored images as paths in generated text? may by using symbols like
[img path=/img_dir/image001.jpg]
This is an old issue, but I have a fork that inserts '----image1.jpg----' in the text where the image was found.
https://github.com/ShayHill/docx2python
This is an old issue, but I have a fork that inserts '----image1.jpg----' in the text where the image was found.
https://github.com/ShayHill/docx2python
thank you .
Afternoon, I modify xml2text fn:
nsmap = {'w': 'http://schemas.openxmlformats.org/wordprocessingml/2006/main', # add. 'dp': 'http://schemas.openxmlformats.org/drawingml/2006/picture', 'dm': 'http://schemas.openxmlformats.org/drawingml/2006/main', 'rs': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'}
def xml2text(xml, document_part = None): ... # add elif child.tag == qn('dp:blipFill'): #print('---> tag:', child.tag) for c in child.iter(): if c.tag == qn('dm:blip'): k = qn('rs:embed') rId = c.attrib[k] break #print('rId:', rId) image_part = document_part.related_parts[rId] text += image_part.partname.split('/')[-1] + '\n'
doc = Document(docx) document_part = doc.part`