Page 1 of 1

Sizing an inserted image - How to ?

PostPosted: Thu Nov 18, 2010 4:19 am
by myjupiler
Hi,

I create documents with dynamic content, including images.
Some images don't have the same size. I would like to stretch them.

After a manual stretch through Word, I see the following change in document.xml :

Before stretch (default image size)
<w:drawing>
<wp:inline distT="0" distB="0" distL="0" distR="0">
<wp:extent cx="2314057" cy="666750"/>
<wp:effectExtent l="19050" t="0" r="0" b="0"/>
...
<pic:spPr><a:xfrm><a:off x="0" y="0"/>
<a:ext cx="2360591" cy="680158"/></a:xfrm>

After stretch
<w:drawing><wp:inline distT="0" distB="0" distL="0" distR="0">
<wp:extent cx="2776868" cy="800100"/>
<wp:effectExtent l="19050" t="0" r="4432" b="0"/>
...
<pic:spPr><a:xfrm><a:off x="0" y="0"/>
<a:ext cx="2832709" cy="816190"/></a:xfrm>

Word seems to have change right property of effectExtent. But I have no clue on what value to put in
the cx and cy

Any idea ?

Re: Sizing an inserted image - How to ?

PostPosted: Thu Nov 18, 2010 8:00 am
by jason
Regarding extent, see http://www.documentinteropinitiative.or ... 1b226.aspx which says:

This element specifies the extents of the parent DrawingML object within the document (i.e. its final height and width).

cx (Extent Length): Specifies the length of the extents rectangle in EMUs. This rectangle shall dictate the size of the object as displayed (the result of any scaling to the original object).


cy (Extent Width): Specifies the width of the extents rectangle in EMUs. This rectangle shall dictate the size of the object as displayed (the result of any scaling to the original object).


Regarding effectExtent, see http://www.documentinteropinitiative.or ... 6bf22.aspx

Sounds like you just need to change cx and cy.

You can set that at the time you insert the image. Or, if your process means you are changing an existing docx, then the easiest ways to find that element are going to be to use XPath (see Getting Started), or with latest svn, TraversalUtil.