AddFromHtml function crashing with Rich Text

Hello,



We are running into one issue with Aspose.Slides for this funciton “table[1, 2].TextFrame.Paragraphs.AddFromHtml”. Here are the details.



We have .Net MVC Web Application and we are using rich textbox control in our web application. We are exporting text from this rich textbox to PowerPoint using Aspose.Slides. We are trying to use this “AddFromHtml” function to convert the Rich text into HTML text and export it to the table in PowerPoint. Here is one sample code line.



tbl[1, 2].TextFrame.Paragraphs.AddFromHtml(RichTextBox.Text.ToString());



We are getting this error message “Index was out of range. Must be non-negative and less than the size of the collection” when the code hits the above line. I have attached the rich text sample file. Based on the attached .HTML file, this is how it should look like in PowerPoint table after it gets exported. In the rich textbox, users can copy and paste data from Word documents, emails or PowerPoint. So we need to consider those scenarios as well.



Please help us to resolve this issue ASAP.



Thank you!

Hi Mitesh,

Thank you for the details.

Please share your complete code with us to reproduce the issue. Also, please let us know which version of Aspose.Slides for .NET are you using at your end. We will check it and get back to you soon.

Thanks & Regards,

Hi Owais,

Here is the complete code of method/function. Under the file properties the Product Version is “13.12.0.0”. Please let me know if this is the right place to look for version.

public void PopulateSlideOne(Project project, ISlide slide)
{
Aspose.Slides.ITable tbl = null;

        foreach (IShape shp in slide.Shapes)
        {
            string shapeName = shp.Name.ToString();

            if (shp is Aspose.Slides.ITable)
            {
                tbl = (Aspose.Slides.ITable)shp;

                if (shp.Name == "Table 22" && slide.SlideNumber == 1)
                {
                    tbl = (Aspose.Slides.ITable)shp;
                    
                    if (project.Summary != null)
                    {
                        tbl[1, 2].TextFrame.Paragraphs.Clear();
                        tbl[1, 2].TextFrame.Paragraphs.AddFromHtml(project.Summary.ToString());// For Project.Summary please use the content of rich text file that I attached earlier.
                    }
                    else
                    {
                        tbl[1, 2].TextFrame.Text = "";
                    }
                }                    
            }
        }
    }

Hope this helps.

Thanks,
Mitesh

Hi Mitesh,

Thank you for sharing the sample code.

I tried your sample code with the latest version of Aspose.Slides for .NET v14.3.0 and I am unable to notice any issue. The HTML is rendering properly to the PPTX table. Please download and try the latest version at your end and let us know if you still face any issue.

Thanks & Regards,