python-docx2txt icon indicating copy to clipboard operation
python-docx2txt copied to clipboard

Image Paths in generated Text

Open rushikesh988 opened this issue 6 years ago • 2 comments

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]

rushikesh988 avatar Mar 16 '18 06:03 rushikesh988

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

ShayHill avatar Jul 18 '19 16:07 ShayHill

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`

superstrings avatar Sep 08 '19 11:09 superstrings