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

Free Support Forum - aspose.com

How to keep Master template font/text color

Hi , i am having a problem with the powerpoint presentation. When i write a powerpoint presentation it should preserv the design and font colors according to the Master template but it doesnt do that, the font colors are black instead of being white according to Master template.

Aspose.Slides Version:

How can i fix that?

My code:
Presentation pres = new Presentation(base.MapPath("~/classes/SlideDatabase/slidekit.pot"));

SqlDataReader reader2 = command.ExecuteReader();

while (reader2.Read())
using (MemoryStream stream = new MemoryStream(reader2.GetSqlBinary(1).Value))

Presentation presentation2 = new Presentation(stream);
Slide srcSld = presentation2.GetSlideByPosition(1);
Slide slide = presentation2.CloneSlide(srcSld, pres.Slides.LastSlidePosition + 1, pres, new SortedList(), true);
uint id = 0x80000000 + reader2.GetByte(2);
slide.ChangeMaster(pres.GetSlideById(id), false);

Then the output:

base.Response.AddHeader(“Content-Transfer-Encoding”, “binary”);
base.Response.AddHeader(“Content-Disposition”, “attachment; filename=” + StaticText.Get(“asset”, “Filename”) + “.ppt”);
base.Response.ContentType = “application/vnd.ms-powerpoint”;

Hi Marry,

Thanks for your interest in Aspose.Slides.

Please use the latest version of Aspose.Slides for .NET 5.2.0 and let us know if the problem is still there. It would be great, if you can provide us POT and PPT files for investigation purpose.

The problem is still there.

I think what went wrong was that i had i had this file with master templates, then later on (after a year or so) i updated and replaced the matching masters, and i believe that is when it all went wrong.
Caus all the new powerpoint presentation i create do follow the colors, but the old one with an old version of masters does not follow the colors.

The question is how can i fix that, and i can also mention that all the presentations are saved in DB with
byte[] array.

I could lookup in the db and check which slide doesnt have a matching color of master? and how would i do that against master template?

Any idea???

Hi Marry,

I have tried to understand the problem
specified by you but unfortunately, I am not able to completely
understand your problem statement. Please share some more details about
your problem along with the POT/PPT files for necessary investigation.
We are really keen to help you but need further details from your side.

We are sorry for your inconvenience.

Hello Tahir,

Let me try again! :slight_smile:

Step 1. I had made a pot file with master templates 2-3 years back
Step 2. I then uploaded Powerpoint presentations into a DB with those master i had
Step 3. Then i changed one of the master template a year ago which is very similar to the original
master template (Step 1)

Step 4. And now i am having problems with colors of the text. The colors of the text are same on
both masters (the new and the old masters have the same text color). When i download a
presentation it gives me a black color instead of giving me a white color of the text.

I hope this explaination was good enough to describe my problem.


Hi Marry,

Thanks for the detail information about your issue. As we requested you earlier, please share your POT and PPT files with us for detail investigation.

Hello Tahir,

Sorry for the late reply.

I managed to gather the pot and ppt files into zip.
I hope this will help solving my issue with the presentations.

Kind regards

Hi Marry,

Thank for sharing the files. I will work on your issue and will let you know about this issue as soon as possible.

Hi Marry,

Please accept my apology for late response. I have successfully generated the PPT file by following your four points and there is no color issue. Please find the generated presentation files in attachment.
Please share your problematic PPT files and code for further investigation.

Thank you Tahir,

If you look at the title in the master it has white color and in the presentation it has black color, how can i make it white color again?

Kind regards

Hi Marry,

Please use the second parameter value in
ChangeMaster method as true instead of false in your code. This will fix the text color problem.

slide.ChangeMaster(pres.GetSlideById(id), true);

Please let us know if you still face any problem.

Hello Tahir,

I followed your instructions and nothing seems to effect that!

Kind regards

Hi Marry,

Please find my solution file in attachment related to your issue. You can change the product1.ppt with any master slides and then try to generate PPT file with this code. I have also attached the database script file.

Step1 will insert presentation file stream into database. Step2 will generate the PPT file by using product1.pot file. Please share the generated PPT file with me by using this code.

Thanks Tahir,

Your example did work, i have to figure out why mine is not working!
But this leaves me into another problem, the layout changes on the slides. Is there a way to change the color of the heading not the rest of the layout?

Hi Marry,

Please use following code snippet to work with text in a shape.

//Open the presentation
Presentation pres = new Presentation(“d:\pptx\slide.ppt”);

//Add Verdana font
FontEntity font = pres.Fonts[0];
FontEntity verdanaFont = new FontEntity(pres, font);
verdanaFont.FontName = “Verdana”;

int verdanaFontIndex = pres.Fonts.Add(verdanaFont);

//Access the first slide
Slide slide = pres.GetSlideByPosition(1);

//Access the third shape
Shape shp = slide.Shapes[2];

//Change its text’s font to Verdana and height to 32
TextFrame tf = shp.TextFrame;
Paragraph para = tf.Paragraphs[0];
Portion port = para.Portions[0];
port.FontIndex = verdanaFontIndex;
port.FontHeight = 32;

//Bolden it
port.FontBold = true;

//Italicize it
port.FontItalic = true;

//Change text color
port.FontColor = Color.FromArgb(0x33, 0x33, 0xCC);

//Change shape background color
shp.FillFormat.Type = FillType.Solid;

shp.FillFormat.ForeColor = Color.FromArgb(0xCC, 0xCC, 0xFF);

//Write the output to disk

Thanks Tahir,

Sorry for my reply, i have been too much busy with my other work!

I have not tried this code yet, but can i somehow change the slides in database to correct them instead?

Kind regards

Hi Marry,

In your scenario, First you need to read presentation from database and change the heading color of slides by using Aspose.Slides. Update the database with presentation object which contain the updated slides.