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

Free Support Forum - aspose.com

How to deal with large content while replacing text of standard slide placeholders in C#

Hi there,

I have multiple text placeholders on a slide. When I replace text of placeholders with large content(text), content goes out of slide area. Is there a way to deal with this situation? Can we have a check when content goes out of slide area and add a new slide so that content might be fit in that? If yes then how?

In the same way, what to do when we have a placeholder for table and after replacing the table placeholder with actual content, the table content goes out of slide area?


Please help.

Hi Pardeep,

Thanks for inquiring Aspose.Slides.

I have observed the requirements shared by you concerning to text spilling out of slide and like to share that there is no automatic way to determine this. However, you can devise a simple approach on your end to serve the purpose. What you need to do is that you check the placeholder height after you add text to placeholder holder. If the Y-Position + height of placeholder is greater than slide height after adding text then it means that text has spilled out of placeholder. Otherwise, you can continue adding text. I hope this will be helpful. Please share, if I may help you further in this regard.

Many Thanks,

Hi Mudassir,

I am not able to implement your above suggested approach. It would be a great help if you could give some piece of code to serve the purpose.Could you also guide me how to get the height of slide?

Do you have any other approach to fix this issue : “how to stop text spilling out of slide”?


Thanks

Hi Pardeep,

I have created a sample example that will help you in understanding the concept to check if the placeholder overflows the slide when adding text or not. Please try using the following sample code on your end to serve the purpose.

public static void AddTextInPlaceholder()
{
StringBuilder Buffer = new StringBuilder();
String text = “Here is long text. This is long text. Long text, Long text, Long text, Here is long text. This is long text. Long text, Long text, Long text”;
Aspose.Slides.Presentation Pres = new Aspose.Slides.Presentation(@“D:\Aspose Data\Test.pptx”);

foreach (Aspose.Slides.Slide Slide in Pres.Slides)
{
foreach (Aspose.Slides.IShape Shape in Slide.Shapes)
{

if (Shape.Placeholder != null)
{
if (Shape.Placeholder.Type == PlaceholderType.Body || Shape.Placeholder.Type == PlaceholderType.Object)
{
while (true)
{

Aspose.Slides.ITextFrame Holder = ((Aspose.Slides.IAutoShape)Shape).TextFrame;
Holder.TextFrameFormat.AutofitType=TextAutofitType.Shape;
IParagraph para = new Paragraph();
para.Text = text;
Holder.Paragraphs.Add(para);

if (Shape.Y + Shape.Height > Pres.SlideSize.Size.Height)
{
Console.WriteLine(“Text Overflowed from Slide”);
}
}
}
}

}
}

}

Many Thanks,