Free Support Forum -

Separating master and content slides

I need to store a lot of PowerPoint slides in a database, where data size matters. All of my slides uses the same design template containing a title master slide and a normal master slide. When saving the slides to the database I would like to remove the masters from the presentation to save precious bytes. When loading the slides back from the database, I would then like to add my masters again to make the slides look like the originals. Does any examples exist on doing something close to what I am describing? Is it even possible to do this kind of content/master seperation.

Thanks :slight_smile:

Master slides usually very small in the ppt files. They are just 100-1000 bytes.
Also if you separate slides and masters then slides will lose most of formatting.
Slides can’t exist without master.

I’d suggest simply zip ppt (for example fast zip mode if time is critical) before
putting it to the database. In this case you will save much more bytes.

Well, my master just happens to contain some background images, causing a difference of approx. 100 % between single slide presentations with or without the master. I understand that a slide cannot live without a master, but it guess it should be possible to delete the heavy master and save all presentations with a default “black-on-white-times-new-roman”-master instead. When loading the slides from the database, it is then my plan to add the correct master and remove the black-on-white dummy master.
Is that a no go?

In this case it’s better to delete background images on master. They stored separately in the ppt file.
As a result your master and slides will save all formatting and in the same time size of ppt will be reduced very much.

That would do the trick as well, yes. What would be the best way to remove all images residing in the master slides of a presentation? And how do I add the original master later - by simply calling the ChangeMaster() method on each slide?

You should iterate all shapes on master slide and do next things:

1. If shape is PictureFrame then you can delete it.

2. For other shapes you need to check FillFormat.Type and for all shapes with FillType.Picture you can replace it with FillType.Solid. Also you can replate large images with something very small.

All unused images will be deleted from ppt file when you save it.

Am I missing anything in the following example, cause it sure does not seem to work.

foreach (Slide master in ppt.Masters)
for (int i = 0; i < master.Shapes.Count; i++)
if (master.ShapesIdea [I] is PictureFrame)
else if (master.ShapesIdea [I].FillFormat.Type == FillType.Picture)
master.ShapesIdea [I].FillFormat.Type = FillType.NoFill;

From inserting breakpoints and doing some debugging, I know that a PictureFrame is actually detected and a shape is removed from my master. However, the output file still has the same image in the background. What am I doing wrong here?

There is one more thing. You should change also the master’s background.

master.Background.FillFormat.Type = FillType.NoFill;

Unfortunatly that did not solve my problem. However it gave me some ideas on where to look, and I now have a more accurate description of the problem I am fighting with: presentation.Masters contains only 1 master, although the file has two masters (one for titles and one for content) when I inspect it from Microsoft PowerPoint. Why is that?

Thanks again :slight_smile:

There are 2 types of masters:

1. Masters of “content” slides. They are MainMaster objects and located in Masters collection.
2. Masters of title slides. They look like normal slides and you can find it in the Slides collection. They have SlidePosition == 0 and SlideId > 0x80000000.

Great, that solved the problems with the persisting images :slight_smile:

I need to do some more working before I can tell if the master slide restore process works. I will be back if I can not make it work myself :slight_smile:

Thanks a lot!