how to set image's width and height when insert an image to Word ? RRS feed

  • Question

  • i had seen the How to insert images in Word2013 using Javascript with OOXML way in URL:

    and i follow the action step by step, the image insert into word correctly!

    but the image which is samller than its original size, so question is how to set image's width and height, the ooxml file i used is like:

    <?xml version="1.0" standalone="yes"?>
    <?mso-application progid="Word.Document"?>
    <pkg:package xmlns:pkg="">
      <pkg:part pkg:name="/_rels/.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:padding="512">
          <Relationships xmlns="">
            <Relationship Id="rId1" Type="" Target="word/document.xml"/>
      <pkg:part pkg:name="/word/_rels/document.xml.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:padding="256">
          <Relationships xmlns="">
            <Relationship Id="rId4" Type="" Target="media/image1.jpg"/>
      <pkg:part pkg:name="/word/document.xml" pkg:contentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml">
          <w:document mc:Ignorable="w14 w15 wp14" xmlns:wpc="" xmlns:mc="" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="" xmlns:m="" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="" xmlns:wp="" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="" xmlns:w14="" xmlns:w15="" xmlns:wpg="" xmlns:wpi="" xmlns:wne="" xmlns:wps="">
              <w:p w:rsidR="00000000" w:rsidRDefault="00C22E3B" w:rsidP="00C22E3B">
                    <wp:inline distT="0" distB="0" distL="0" distR="0" wp14:anchorId="741DD13B" wp14:editId="36F0B4C1">
                      <wp:extent cx="676275" cy="507206"/>
                      <wp:effectExtent l="0" t="0" r="0" b="7620"/>
                      <wp:docPr id="5" name="Picture 5"/>
                        <a:graphicFrameLocks noChangeAspect="1" xmlns:a=""/>
                      <a:graphic xmlns:a="">
                        <a:graphicData uri="">
                          <pic:pic xmlns:pic="">
                              <pic:cNvPr id="1" name="Image.png"/>
                              <a:blip r:embed="rId4">
                                  <a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
                                    <a14:useLocalDpi val="0" xmlns:a14=""/>
                                <a:off x="0" y="0"/>
                                <a:ext cx="678661" cy="508996"/>
                              <a:prstGeom prst="rect">
              <w:sectPr w:rsidR="00000000">
                <w:pgSz w:w="12240" w:h="15840"/>
                <w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="720" w:footer="720" w:gutter="0"/>
                <w:cols w:space="720"/>
      <pkg:part pkg:name="/word/media/image1.jpg" pkg:contentType="image/png" pkg:compression="store">

    which {Replace} is replace by the image code.

    Saturday, July 6, 2013 2:30 PM


All replies

  • i know the key is cx and cy, it is the image's width and height

    but how to change width and height to cx and cy

    for example :

     my image is 400*400

    what is the cx and cy's value?

    Saturday, July 6, 2013 2:51 PM
  • Hi Shuichao,

    The cx and cy values are in "EMU" units (for example, see  There are 9525 EMUs per pixel, so multiply 400*9525 and you should be able to use those values for the cx and cy.

    Hope this helps,

    - Michael

    Michael Zlatkovsky | Program Manager, Visual Studio Tools for Office & Apps for Office

    Tuesday, July 9, 2013 6:42 PM