views:

23

answers:

1

Hi

Im am generating a ppt-file using this tutorial here

Step 4 describes how to swap out the image placeholder. My images has different dimensions, which makes some images look a little bit too funny.

Is there any way to resize the placeholder so it can keep the dimensions?

Thanks/

Edit: Ok, a better explanation: users can upload images of them selves. The images are stored on the server. I am generating a ppt-file with one user per slide. And for every slide there will be an image, if any. I can of course get the dimensions of every image, but how do I replace the placeholder with an image of another dimension than the placeholder?

A: 

Well, I can't tell you based on that tutorial, but I can tell you where it is done in Open XML (i.e. not the SDK).

Your picture will have an xfrm element with a set of values, like this:

    <p:spPr>
      <a:xfrm>
        <a:off x="7048050" y="6248401"/>
        <a:ext cx="972000" cy="288000"/>
      </a:xfrm>
    </p:spPr>

The values you want to change are the cx and cy of a:ext. Take your new picture's dimensions (h and w) from like a System.Drawing.Image object and take each of the values and multiply by 12700. So if the width of the picture is 400 pixels, the cx value of a:ext will be (400 x 12700 = 5080000).

Otaku
Thank you Otaku.
Mr. Powerpoint
I have been googling for a while. I cant find any examples on how to set these values. That is, to temper with the xml file.Can you please post some url:s ?Thanks again
Mr. Powerpoint
@Mr. Powerpoint: Found a good article on using the Open XML SDK for creating a slide deck with images: http://msdn.microsoft.com/en-us/library/ee412267(office.12).aspx. What is mentioned above - `<a:xfrm/>` is the `Extents` class.
Otaku