<w:pict> docx element not being picked up with Python-docx code

Viewed 12

I am using the code given at https://github.com/kmrambo/Python-docx-Reading-paragraphs-tables-and-images-in-document-order-

This code works fine for paragraphs and tables and even images that I paste in a document myself, however, the documents which I am trying to process have a problem. When running this code, the image list is empty. Upon further inspection, I managed to find the difference in the way images are stored in the XML.

The code works fine if the images are stored in the following format. This happens if I paste an image into docx manually:

                    <pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
                       <pic:nvPicPr>
                          <pic:cNvPr id="0" name="Picture 1"/>
                          <pic:cNvPicPr>
                             <a:picLocks noChangeArrowheads="1" noChangeAspect="1"/>
                          </pic:cNvPicPr>
                       </pic:nvPicPr>
                       <pic:blipFill>
                          <a:blip r:embed="rId4">
                             <a:extLst>
                                <a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
                                   <a14:useLocalDpi val="0" xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main"/>
                                </a:ext>
                             </a:extLst>
                          </a:blip>
                          <a:srcRect/>
                          <a:stretch>
                             <a:fillRect/>
                          </a:stretch>
                       </pic:blipFill>
                       <pic:spPr bwMode="auto">
                          <a:xfrm>
                             <a:off x="0" y="0"/>
                             <a:ext cx="3743325" cy="2962275"/>
                          </a:xfrm>
                          <a:prstGeom prst="rect">
                             <a:avLst/>
                          </a:prstGeom>
                          <a:noFill/>
                          <a:ln>
                             <a:noFill/>
                          </a:ln>
                       </pic:spPr>
                    </pic:pic>

However, the documents I am working with use the following format which isn't picked up by the Python code:

                 <w:pict w14:anchorId="71E2ADA8">
                    <v:shape id="_x0000_i1062" style="width:185.15pt;height:174.85pt" type="#_x0000_t75">
                       <v:imagedata o:title="" r:id="rId56"/>
                    </v:shape>
                 </w:pict>

I'm not sure how to configure the code to deal with this difference

Sample docx file that I'm working with can be found at: https://www.3gpp.org/ftp//Specs/archive/21_series/21.914/21914-e00.zip

0 Answers
Related