wordpress hit counter
Inserting an image using WordDrawingML without a-priori information about image width/heigh - WordprocessingML - Formats - OpenXML Developer

Inserting an image using WordDrawingML without a-priori information about image width/heigh

Formats

Discussions about working with different Open XML Formats

Inserting an image using WordDrawingML without a-priori information about image width/heigh

  • rated by 0 users
  • This post has 1 Reply |
  • 0 Followers
  • Hi there,
    Trying to add an image to a docx package, I understood I have to copy the image file into a certain folder, then add a relationship line, a contenttype line, and finally insert the follwing chunck of xml data into document.xml :

    <w:drawing>
                        <wp:inline distT="0" distB="0" distL="0" distR="0">
                            <wp:extent cx="1270000" cy="977900" />
                            <wp:effectExtent l="19050" t="0" r="6350" b="0" />
                            <wp:docPr id="1" name="Picture 0" descr="34055202s.jpg" />
                            <wp:cNvGraphicFramePr>
                                <a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1" />
                            </wp:cNvGraphicFramePr>
                            <a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
                                <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
                                    <pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
                                        <pic:nvPicPr>
                                            <pic:cNvPr id="0" name="34055202s.jpg" />
                                            <pic:cNvPicPr />
                                        </pic:nvPicPr>
                                        <pic:blipFill>
                                            <a:blip r:embed="rId6" />
                                            <a:stretch>
                                                <a:fillRect />
                                            </a:stretch>
                                        </pic:blipFill>
                                        <pic:spPr>
                                            <a:xfrm>
                                                <a:off x="0" y="0" />
                                                <a:ext cx="1270000" cy="977900" />
                                            </a:xfrm>
                                            <a:prstGeom prst="rect">
                                                <a:avLst />
                                            </a:prstGeom>
                                        </pic:spPr>
                                    </pic:pic>
                                </a:graphicData>
                            </a:graphic>
                        </wp:inline>
                    </w:drawing>


    The problem is that for such chunk to be working the heigh/width of image need be known.
    Is there a way how i can add such chunk without the need to know the information about dimensions ?

    Thank you in advance.
  • I ended up integrating a jpeg parser to read the dimensions of the image before supplying those values into the wordml chunk.
    It seems there's nothing like 100% , ie relative dimensions, etc
Page 1 of 1 (2 items)