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

Free Support Forum - aspose.com

Reformatting place holders in the footer

Hi,


I am trying to change the alignment of the slide number place holder but not having any success. Here is what I am trying to do:

IMasterSlide currentSlide = doc.Masters[0];

Drawing.Rectangle footerArea = new Drawing.Rectangle(ReportConstants.DEFAULT_MARGIN_SIDE_SMALL, (int)slideSize.Height - ReportConstants.DEFAULT_MARGIN_BOTTOM,
(int)slideSize.Width - (ReportConstants.DEFAULT_MARGIN_SIDE_SMALL*2), ReportConstants.DEFAULT_MARGIN_BOTTOM);

foreach(IShape s in currentSlide.Shapes)
{
if (s.Placeholder != null)
if((s.Placeholder.Type == PlaceholderType.SlideNumber ) ||
(s.Placeholder.Type == PlaceholderType.Footer) ||
(s.Placeholder.Type == PlaceholderType.DateAndTime))
{
IAutoShape shape = (IAutoShape)s;
shape.Y = footerArea.Top;
shape.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FontHeight = 9;
shape.TextFrame.Paragraphs[0].ParagraphFormat.Alignment = (s.Placeholder.Type == PlaceholderType.SlideNumber) ? TextAlignment.Right : TextAlignment.Left;
shape.TextFrame.TextFrameFormat.AnchoringType = TextAnchorType.Center;
shape.TextFrame.TextFrameFormat.TextStyle.DefaultParagraphFormat.Alignment = (s.Placeholder.Type == PlaceholderType.SlideNumber) ? TextAlignment.Right : TextAlignment.Left;
shape.TextFrame.TextFrameFormat.AutofitType = TextAutofitType.Shape;
if(s.Placeholder.Type == PlaceholderType.SlideNumber)
shape.X = footerArea.Right - shape.Width;
}
}


I am able to change the font size but not the alignment. Can you help with this?

Thanks,
Karthik

Hi Karthik,

Thank you for the sample code.

Please share your sample input and generated output file with us to reproduce the issue at our end. We will check it and get back to you. Also, please let us know which version of Aspose.Slides for .NET are you using.

Thanks & Regards,

Hi Owais,


You could just run this code snippet on a sample presentation object and add a couple of slides:

doc = new Presentation();
IMasterSlide currentSlide = doc.Masters[0];
foreach(IShape s in currentSlide.Shapes)
{
if (s.Placeholder != null)
if((s.Placeholder.Type == PlaceholderType.SlideNumber ))
{
IAutoShape shape = (IAutoShape)s;
shape.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FontHeight = 9;
shape.TextFrame.Paragraphs[0].ParagraphFormat.Alignment = (s.Placeholder.Type == PlaceholderType.SlideNumber) ? TextAlignment.Right : TextAlignment.Left;
shape.TextFrame.TextFrameFormat.TextStyle.DefaultParagraphFormat.Alignment = (s.Placeholder.Type == PlaceholderType.SlideNumber) ? TextAlignment.Right : TextAlignment.Left;
}
}
//add a few slides and save the ppt at this point.

The alignment for the slide number placeholder does not move to the right as requested. As you can see I have tried to change both default paragraph alignment and the alignment in the placeholder shape itself. Neither of these seem to work.

Thanks,
Karthik.


Additional info: This only affects the PPT save format and not the PPTX save format.

Hi Karthik,

I checked your issue as per the code shared by you and I can see that alignment is working fine when saving the file as PPTX but when saving as PPT, alignment is not working fine. Are you facing the same issue. I would request you to share your complete code and both generated files with us as well so we can investigate the issue exactly as you are facing it.

Thanks & Regards,