S
Simon Turner
Hello Powerpoint experts.
I am having proplems exporting images from powerpoint 2002 using c#
(.Net) The issue im having is that the images are not of there
original size when they are exported.
When i export using the powerpoint saves as dialog the sample image is
760/512 but when i export using api's the image is only 365/246.
The method i am using is as follows:
1.Loop through all shapes in presentation (not shown)
2. If shape is type MsoPicture then i want to export it (not shown)
3. Copy it
4. Create a new blank presentation with one slide on and resize it to
size of shape and paste the shape there.
5. Then export the slide as a jpg.
Here is the C# source code:
//copy picture
myShape.Copy();
//create new presentation set size to size of picture
PowerPoint.Presentation myPres =
pptApp.Presentations.Add(MsoTriState.msoFalse);
myPres.PageSetup.SlideHeight = height;
myPres.PageSetup.SlideWidth = width;
//add a blank slide
PowerPoint.Slide mySlide=
myPres.Slides.Add(1,PowerPoint.PpSlideLayout.ppLayoutText);
//paste the shape and set to top left
PowerPoint.ShapeRange myRange= mySlide.Shapes.Paste();
myRange.Top = 0;
myRange.Left = 0;
//scale the shape to 100% of original size
myRange.LockAspectRatio = MsoTriState.msoTrue;
myRange.ScaleWidth((float)1,MsoTriState.msoTrue,
MsoScaleFrom.msoScaleFromTopLeft);
myRange.ScaleHeight((float)1,MsoTriState.msoTrue,
MsoScaleFrom.msoScaleFromTopLeft);
//export slide and close presentation
mySlide.Export(filename,"JPG",0,0);
myPres.Close();
This produces the results i discribed above. I've looked at all the
resouces i can on this one and still cant get the original size of the
image out, its just weird! Im just wondering if anyone has managed to
do this and if so what am i doing wrong?
Thanks a lot for your help people and all the best.
Simon Turner
I am having proplems exporting images from powerpoint 2002 using c#
(.Net) The issue im having is that the images are not of there
original size when they are exported.
When i export using the powerpoint saves as dialog the sample image is
760/512 but when i export using api's the image is only 365/246.
The method i am using is as follows:
1.Loop through all shapes in presentation (not shown)
2. If shape is type MsoPicture then i want to export it (not shown)
3. Copy it
4. Create a new blank presentation with one slide on and resize it to
size of shape and paste the shape there.
5. Then export the slide as a jpg.
Here is the C# source code:
//copy picture
myShape.Copy();
//create new presentation set size to size of picture
PowerPoint.Presentation myPres =
pptApp.Presentations.Add(MsoTriState.msoFalse);
myPres.PageSetup.SlideHeight = height;
myPres.PageSetup.SlideWidth = width;
//add a blank slide
PowerPoint.Slide mySlide=
myPres.Slides.Add(1,PowerPoint.PpSlideLayout.ppLayoutText);
//paste the shape and set to top left
PowerPoint.ShapeRange myRange= mySlide.Shapes.Paste();
myRange.Top = 0;
myRange.Left = 0;
//scale the shape to 100% of original size
myRange.LockAspectRatio = MsoTriState.msoTrue;
myRange.ScaleWidth((float)1,MsoTriState.msoTrue,
MsoScaleFrom.msoScaleFromTopLeft);
myRange.ScaleHeight((float)1,MsoTriState.msoTrue,
MsoScaleFrom.msoScaleFromTopLeft);
//export slide and close presentation
mySlide.Export(filename,"JPG",0,0);
myPres.Close();
This produces the results i discribed above. I've looked at all the
resouces i can on this one and still cant get the original size of the
image out, its just weird! Im just wondering if anyone has managed to
do this and if so what am i doing wrong?
Thanks a lot for your help people and all the best.
Simon Turner