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

Free Support Forum - aspose.com

Add Text and logo in slides- Power Point

Hi Wade,

I have tried to understand the issue shared by you and regret to share that I am unable to completely understand the issue shared. Please share the source presentation along with code snippet to elaborate the issue completely. I really appreciate your cooperation for that.

Thanks and Regards,

The attached ppt has a date/time field in the footer. I need to be able to replace this date/time with arbitrary text. When I follow your example code, my text is appended to the date/time, rather than replacing it:



if (presentation is Presentation)

{

Presentation pres = presentation as Presentation;



Slide slide = null;

int numSlides = pres.Slides.LastSlidePosition;



for (int slideNum = 1; slideNum
{

slide = pres.GetSlideByPosition(slideNum);

//slide = pres.MainMaster as Slide;



foreach (Shape shape in slide.Shapes)

{

if (shape.TextFrame != null)

{

TextFrame frame = shape.TextFrame;

if (frame.MetaCharacters != null)

{

MetaCharacterType type = frame.MetaCharacters[0];

switch (type)

{

case MetaCharacterType.DateTime:

frame.Paragraphs[0].Portions[0].Text = “[Autotext]”;

break;

case MetaCharacterType.Footer:

break;

case MetaCharacterType.GenericDateTime:

break;

case MetaCharacterType.Header:

break;

case MetaCharacterType.SlideNumer:

break;

default:

break;

}

}

}

}

}

}

Hi Wade,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I like to share that you may not replace the metacharacters associated with any text frame. However, you can copy the properties of DateTime field and create a new similar shape and add the desired text yourself. For your kind reference, I have updated the code snippet shared by you and hopefully it will help you in resolving the issue.

Presentation pres = new Presentation("D:\\Aspose Data\\YesHeaderFooterNotesAuto.ppt");

Slide slide = null;

int numSlides = pres.Slides.LastSlidePosition;

int x=0, y=0, w=0, h=0;

for (int slideNum = 1; slideNum<pres.Slides.Count;slideNum++)

{

slide = pres.GetSlideByPosition(slideNum);

foreach (Shape shape in slide.Shapes)

{

if (shape.TextFrame != null)

{

TextFrame frame = shape.TextFrame;

if (frame.MetaCharacters != null)

{

MetaCharacterType type = frame.MetaCharacters[0];

switch (type)

{

case MetaCharacterType.DateTime:

slide.HeaderFooter.DateTimeVisible = false;

slide.HeaderFooter.IsDateTimeVisible = false;

x = shape.X;

y = shape.Y;

w = shape.Width;

h = shape.Height;

break;

case MetaCharacterType.Footer:

break;

case MetaCharacterType.GenericDateTime:

break;

case MetaCharacterType.Header:

break;

case MetaCharacterType.SlideNumer:

break;

default:

break;

}

}

}

}

if (x >= 0 && y >= 0)

{

Shape temshape = slide.Shapes.AddRectangle(x, y, w, h);

temshape.AddTextFrame("Hello World");

}

}

pres.Write("D:\\Aspose Data\\TestDate.ppt");

Thanks and Regards,

This is an acceptable workaround. Thanks. Do you know of any way I can do the same thing in a pptx file?

Hi Wade,

I regret to share that MS PowerPoint 2007 does not add real headers and footers, rather it adds normal rectangle shapes as headers and footers. In the current Aspose.Slides API, ShapeEx.AlternativeText property can be used to identify a shape provided the creator of the presentation adds unique "Alternative Text" to shapes. You can add a shape and add the slide index in the text of that rectangle to show slide number. Other option is to use a template PPTX slide, that has been created in PowerPoint and has macro enabled slide number.

Thanks and Regards,