We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Transfering Fonts from a Master Slide


We have run into problems using master slides, whereby font styling in the master slide is not transferred to any slides based upon it. I'm not even sure just now how it is even *supposed* to work at all.

The goal is for empty slides, which we fill with text using aspose commands, to "inherit" the font properties/style from a master.pot template.

Following (more or less) your example here http://www.aspose.com/community/forums/79025/showthread.aspx we extract a slide from a .pot file, and then add text to it using the usual aspose style commands e.g.

Aspose.Slides.Rectangle titleRect = _layoutSlide.Shapes.AddRectangle(PageMarginLeft, PageMarginTop, _pres.SlideSize.Width - PageMarginLeft - PageMarginTop, 350);
            titleRect.LineFormat.ShowLines = ShowLines;
            titleRect.AddTextFrame("Title Area");
            titleRect.AlternativeText = "SHAPE_title";
            titleRect.Name = "title";

The texts we create using Aspose remain as "Arial" rather than the fonts used in the master template.

I expected we might be able to make this work in a few ways. e.g. I *expected* to find that :

* One could define the type of font and properties for a paragraph style (e.g. Header / Body) which we could then look up from the master slide and apply programmatically depending on the purpose for which we wish to use a text created by aspose

* One could define a TextArea in Aspose as belonging to one of a set of (Microsoft?) defined types like "Header", "Body", and Aspose would extract the appropriate font styling from similar elements in the master template.

Neither of these approaches seem to exist. I am a bit confused about how fonts are supposed to be mapped from a template to aspose generated texts at all!

Could you send us an example, or a link to where this is explained? So far we haven't found anything helpful in the aspose documentation or examples.

Many thanks.


Hi Ben,

Thanks for your interest in Aspose.Slides.

I have tried to understand your problem statement and based on my understanding please visit this link to work with font. You can also set font information of a shape in master slide and apply that setting to shapes in slides. Let me know, If you have any further queries.

That isn't actually very helpful.

Just so others don't waste time on this :

*) PowerPoint doesn't seem to have anything like paragraph styles.

*) You can't "type" text areas in a template, but you can recover them as shapes.

How we have proceeded to extract and use font information from a template in rendered slides is :

1) To create a new slide from our template, and extract the first two shapes, the first relates to the "Title" and the second to the "Body".

1.1) We sample these Shapes to extract various font properties (colour/size/name/bold etc.).

2) All of the texts created by default by Aspose use the same font index. Therefore, if done before any texts are rendered, altering the FontName on that index in a Presentations Font collection (pres.Fonts[portion.FontIndex].FontName = fontType;)

causes all subsequent fonts to render in the correct style.

3) Finally, all text setting happens through a helper method which picks up the requires font properties and applies them.

Hi Ben,

Please accept my apology for late response. Please use the following code snippet to get the information of shape (color, size, itlalic, underline, bold, font etc). You can get the FindShape method from this documentation link.

I have added a master slide to attached PPT file and added a text frame in master slide with some text. Please find the sample PPT file in attachment.

Presentation pres = new Presentation(@“d:\pptx\Sample.ppt”);
//get master slide
Slide mSlide = pres.Masters[1];
//get source shape
Aspose.Slides.Rectangle sourceShp = (Aspose.Slides.Rectangle)FindShape(mSlide, “sampleRect”);

//Get text information
Boolean bold = sourceShp.TextFrame.Paragraphs[0].Portions[0].FontBold;
Boolean italic = sourceShp.TextFrame.Paragraphs[0].Portions[0].FontItalic;
Boolean underline = sourceShp.TextFrame.Paragraphs[0].Portions[0].FontUnderline;
//get text color
Color color = sourceShp.TextFrame.Paragraphs[0].Portions[0].FontColor;
//get shape fill color
Color shpColor = sourceShp.TextFrame.FillFormat.ForeColor;

//get font index
int index = sourceShp.TextFrame.Paragraphs[0].Portions[0].FontIndex;
//you can get the font family, name etc with font object
FontEntity font = pres.Fonts[index];

short height = sourceShp.TextFrame.Paragraphs[0].Portions[0].FontHeight;
You can set the same properties to a text frame as well. Hope this answers your query.