Get Slide Title Text for Each Slide - Aspose.Slides .NET

Last post 09-08-2011, 11:03 PM by Mudassir. 2 replies.
Sort Posts: Previous Next
  •  09-08-2011, 9:04 PM 328034

    Get Slide Title Text for Each Slide - Aspose.Slides .NET .NET

    I want to get the title of each slide. I have been testing with the code below.
    However, it only returns the type of each Shape, not the actual text that is in the Shape.


    //Instantiate a PresentationEx class that represents the PPTX file
    PresentationEx pres = new PresentationEx(tbPPTpath.Text);
    int iSlideCount = pres.Slides.Count;
    for (int ind = 0; ind < iSlideCount; ind++)
    {
    //Access each slide
    SlideEx sld = pres.Slides[ind];
    pres.Slides[ind].Name.ToString();

    ShapesEx curShapes = sld.Shapes;
    for (int indShapes = 0; indShapes < curShapes.Count; indShapes++)
    {
    if (curShapes[indShapes].IsTextHolder && !String.IsNullOrEmpty(curShapes[indShapes].Name))
    {
    lbTitles.Items.Add("Slide " + (ind + 1).ToString() + ": " + curShapes[indShapes].Name.ToString());
    }
    }

    lblStatus.Text = "Saving Slide " + (ind + 1).ToString() + " of " + iSlideCount.ToString();
    Application.DoEvents();

     
  •  09-08-2011, 10:42 PM 328037 in reply to 328034

    Re: Get Slide Title Text for Each Slide - Aspose.Slides .NET

    It looks like I figured it out myself.
    I posted my code below, if anyone wants to refer to it.

    Thanks!

    //Instantiate a PresentationEx class that represents the PPTX file
    PresentationEx pres = new PresentationEx(tbPPTpath.Text);
    int iSlideCount = pres.Slides.Count;
    for (int ind = 0; ind < iSlideCount; ind++)
    {
    //Access each slide
    SlideEx sld = pres.Slides[ind];

    foreach (ShapeEx shp in sld.Shapes)
    {
    string sTitleText = null;
    string sTitleType = null;
    try
    {
    sTitleText = ((AutoShapeEx)shp).TextFrame.Text.ToString();
    sTitleType = ((AutoShapeEx)shp).Name.ToString();
    }
    catch (Exception ex)
    { }

    if (!String.IsNullOrEmpty(sTitleText))
    {

    if (shp.IsTextHolder && sTitleType.Contains("Title"))
    {
    lbTitles.Items.Add("Slide " + (ind + 1).ToString() + ": " + sTitleText);
    }
    else if (shp.Placeholder != null && sTitleType.Contains("Title"))
    {

    lbTitles.Items.Add(((AutoShapeEx)shp).TextFrame.Text);
    }
    }
    }

     
  •  09-08-2011, 11:03 PM 328039 in reply to 328037

    Re: Get Slide Title Text for Each Slide - Aspose.Slides .NET

    Hi John,

    It's really great to listen that you have managed to figure out the requirements your self. Please share if I may be of any further to you in this regard.

    Many Thanks,


    Mudassir Fayyaz
    Support Developer
    Aspose Sialkot Team
    Contact Us
    Aspose - The .NET and Java Component Publisher

    Keep in touch! We're on Twitter and Facebook
     
View as RSS news feed in XML