Extracting Powerpoint Slide Information

S

Saurabh

Hi,

I am trying to work on exporting PPT into some proprietary format which can
be displayed in our application. Currently we export PPT slides to Jpg images
and embed those images in our application but then we loose upon the
animation. Now we want support animation as well. For that I tried to go
through the basic architecture of PPT, but couldn't find something which will
give out all the details about how to extract information about slides,
shapes, from PPT. If anyone have some good samples that I can try out please
let me know. Even some links which might be helpful.

I was trying to export the background of the slide to an image, but I am
only able to do that for the master slide and it doesn't work for the next
slides. For exporting background I am using following code:

slide.Background.Export("SlideBack.jpg", PpShapeFormat.ppShapeFormatJPG,
slide.Master.Height,slide.Master.Width, PpExportMode.ppRelativeToSlide);

But it only works for Master slide, remaining all slides background is
exported as complete black image. Can somebody tell me how to achieve this?

Other information that I was trying to extract from PPT was the position of
Shapes in slide. I get the left, top, right and bottom information on shape
but looks like it’s not correct, when I try to replicate same thing on SWF,
the position looks slightly shifted to left and top, so I was thinking that I
might be missing out on some of the margin values like Header or left/top
margin. I looked at the MarginLeft, MarginTop properties of TextFrame of my
current slide but it show 0 there. what is the difference between TextFrame
and TextFrame2?

How to extract information about margin length on the slide, and also how to
find the height and width of Header/Footer from the slide.

-Saurabh
 
S

Steve Rindsberg

I am trying to work on exporting PPT into some proprietary format which can
be displayed in our application. Currently we export PPT slides to Jpg images
and embed those images in our application but then we loose upon the
animation. Now we want support animation as well. For that I tried to go
through the basic architecture of PPT, but couldn't find something which will
give out all the details about how to extract information about slides,
shapes, from PPT. If anyone have some good samples that I can try out please
let me know. Even some links which might be helpful.

This may help ... look for animation-related links on the page:
http://skp.mvps.org/vba.htm
I was trying to export the background of the slide to an image, but I am
only able to do that for the master slide and it doesn't work for the next
slides. For exporting background I am using following code:

slide.Background.Export("SlideBack.jpg", PpShapeFormat.ppShapeFormatJPG,
slide.Master.Height,slide.Master.Width, PpExportMode.ppRelativeToSlide);

Try creating a duplicate slide, deleteing all the shapes on it, then exporting
the slide.
Other information that I was trying to extract from PPT was the position of
Shapes in slide. I get the left, top, right and bottom information on shape
but looks like it’s not correct, when I try to replicate same thing on SWF,
the position looks slightly shifted to left and top, so I was thinking that I
might be missing out on some of the margin values like Header or left/top
margin. I looked at the MarginLeft, MarginTop properties of TextFrame of my
current slide but it show 0 there.

The current slide has no margin properties; text frames do.
The text frame's margintop and marginleft will, if > 0, shift the text right and
down, so if you place text in SWF at the shape's Top and Left position, it would
be offset slightly. Try placing it at the shape's Top + TextFrame.MarginTop
position instead.
what is the difference between TextFrame
and TextFrame2?

TextFrame2 exposes the new text properties introduced in PPT 2007.
How to extract information about margin length on the slide,

As above, there isn't any margin on the slide, only on the textframes of
individual shapes.
and also how to
find the height and width of Header/Footer from the slide.

That'd depend on what version of PPT you're working in.

In 2007 you'd iterate through the slide's Shapes collection looking for a shape
of the correct type (ie, ppPlaceholderDate for example).

In earlier versions, you'd do more or less the same thing but on the slide's
master, and would have to check to see if the placeholder is set to be visible
or not (if not, it wouldn't appear on the slide itself).
 
S

Saurabh

Hi Steve,

Thanks for the reply. Those were really great answers my problems.
Steve, I was wondering if I am following the right path by using the
Powerpoint COM dlls. Do you think those DLLs expose all the information which
one might need to export PPT with animation in some propriatory formats
similar to SWF. or Should I go for reading the PPT file format? I am slightly
confused. Please provide your view, do you think one can develop an export
(with animation) application with the help of Powerpoint DLL.

I had another couple of questions about extracting information from PPT
using Powerpoint DLL:

1) How to get embeded images from PPT-slide in their original sizes or as
per they look on slides?
We tried to use shape.export() method where shape-type was 'msoPicture' like
=>

curShape.Export(imgName,PpShapeFormat.ppShapeFormatJPG,(int)curShape.Width,
(int)curShape.Height, PpExportMode.ppRelativeToSlide);

Image is getting exported , but in very small size than how it looks on PPT.
Need advice on what should be values for 'ScaleWidth', 'ScaleHeight' and
'PpExportmode' parameters of 'Export()' function.

2. How to export picture used for 'picture-bullet' ?


Thanks in advance.

-Saurabh
 
S

Steve Rindsberg

Thanks for the reply. Those were really great answers my problems.

Glad I could help.
Steve, I was wondering if I am following the right path by using the
Powerpoint COM dlls. Do you think those DLLs expose all the information which
one might need to export PPT with animation in some propriatory formats
similar to SWF. or Should I go for reading the PPT file format? I am slightly
confused. Please provide your view, do you think one can develop an export
(with animation) application with the help of Powerpoint DLL.

I'd be inclined to automate PowerPoint rather than trying to read the file
formats. If you try to work with the files directly you'd have to read two
entirely different formats, the older 97-2003 binary format and the new XML
format. By automating PowerPoint, that's taken care of for you.
1) How to get embeded images from PPT-slide in their original sizes or as
per they look on slides?

The simplest thing seems to be saving the presentation as HTML then working out
which image is which.
2. How to export picture used for 'picture-bullet' ?

That picture will be among the files created when you save as HTML also.
 
S

Saurabh

Hi Steve,

I am trying to show the paragraph with bullets.
I am able to get all the TextRange in my shape using TextRange from
Shape.TextFrame.TextRange.Paragraph(i).

After trying out few things, I understood that, I will have to use
Shape.TextFrame.MarginLeft,MarginRight,MarginTop, MarginBottom properties as
well to get exact co-ordinates for my controls inside the shape.
I am also getting the
Shape.TextFrame.TextRange.Paragraph(i).BoundLeft,BoundTop, BoundWidth,
BoundHeight from my paragraph text range.
I am even able to extract the Ruler values, first and left margine of all
the ruler values.

But now I am totally confused as to which one to use and how to set the
proper left and top values for my controls (two controls, 1) to show bullet
2) to show text) in my swf.

Logically I feel that the calculation for setting the left and top values
for bullet should be => shape.left + ruler(0).first + leftmargine
And for text should be => shape.left + ruler(0).left + leftmargine

But if I use these parameters then it doesn't render it properly in the swf.
But for showing Bullet if I use calculation as => shape.left - (leftmargine
+ rightmargine)
Then its rendered corectly.

But I am not able to understand why should I substract margine values, I
think I should add them, Right?

Can you throw some light on this?
 
S

Steve Rindsberg

Hi Steve,

I am trying to show the paragraph with bullets.
I am able to get all the TextRange in my shape using TextRange from
Shape.TextFrame.TextRange.Paragraph(i).

After trying out few things, I understood that, I will have to use
Shape.TextFrame.MarginLeft,MarginRight,MarginTop, MarginBottom properties as
well to get exact co-ordinates for my controls inside the shape.
I am also getting the
Shape.TextFrame.TextRange.Paragraph(i).BoundLeft,BoundTop, BoundWidth,
BoundHeight from my paragraph text range.
I am even able to extract the Ruler values, first and left margine of all
the ruler values.

But now I am totally confused as to which one to use and how to set the
proper left and top values for my controls (two controls, 1) to show bullet
2) to show text) in my swf.

Logically I feel that the calculation for setting the left and top values
for bullet should be => shape.left + ruler(0).first + leftmargine
And for text should be => shape.left + ruler(0).left + leftmargine

But if I use these parameters then it doesn't render it properly in the swf.
But for showing Bullet if I use calculation as => shape.left - (leftmargine
+ rightmargine)
Then its rendered corectly.

But I am not able to understand why should I substract margine values, I
think I should add them, Right?

Can you throw some light on this?


I'm having trouble making sense of what you're seeing too, Saurabh.
One thing that usually helps me to sort this kind of thing out, though, is to
write a bit of quick VBA in PPT to draw rectangles where I *think* they should
be and work out if what I expect is actually correct.

Also, remember that with PPT 2007, each paragraph can have its own indent and
tab settings, unlike earlier versions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top