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

Free Support Forum - aspose.com

How extract text from a master slide

Hello,


We are developping a aplication to extract all kind of text from a pptx file. The application works fine with all text, except for the text inside de masters slides.

This is the snipet that we use for that kind of slides:

IMasterSlideCollection masterSlide = presentation.getMasters();
if (null != masterSlide) {
for(IMasterSlide sl : masterSlide)
{
// sl.
for (IShape shape : sl.getShapes()) {
System.out.println("-- -2- Shape “+ shape.getClass().getName());
if (shape.getPlaceholder() != null) {
System.out.println(”-- – -- PlaceHolder: ["+shape.getPlaceholder().getType()+"]");

// if (shape.getPlaceholder().getType() == PlaceholderType.Header || shape.getPlaceholder().getType() == PlaceholderType.Footer ) {

ITextFrame tfn = ((IAutoShape) shape).getTextFrame();

if (tfn != null && !tfn.getText().isEmpty()) {
System.out.println("-- – -- Text MASTERSLIDE ["+tfn.getText()+"]");
IParagraphCollection paras = tfn.getParagraphs();

for(IParagraph parag : paras)
{
processParagraphEx(parag, markCharacters, segmentationConditions, segmentationExceptions, presentation);
}
}
// }
}
}
}
}


As Attachment are the original pptx file were are using.

May you help us how to do it?


Sincerely,


AT




Hi Jaume,

I have observed your requirement and suggest you to please try using following modified code on your end to extract all text from master slide.

public static void ExtractMasterText()
{
Presentation presentation=new Presentation(“C:\Aspose Data\Test.pptx”);
IMasterSlideCollection masterSlide = presentation.getMasters();

if (null != masterSlide)
{
for(IMasterSlide sl : masterSlide)
{
for (IShape shape : sl.getShapes())
{
// System.out.println("-- -2- Shape “+ shape.getClass().getName());
//if (shape.getPlaceholder() != null)
if (shape instanceof IAutoShape)
{
// System.out.println(”-- – -- PlaceHolder: ["+shape.getPlaceholder().getType()+"]");

// if (shape.getPlaceholder().getType() == PlaceholderType.Header || shape.getPlaceholder().getType() == PlaceholderType.Footer ) {

ITextFrame tfn = ((IAutoShape) shape).getTextFrame();

if (tfn != null && !tfn.getText().isEmpty())
{
// System.out.println("-- – -- Text MASTERSLIDE ["+tfn.getText()+"]");
IParagraphCollection paras = tfn.getParagraphs();

for(IParagraph parag : paras)
{
System.out.println("Para text: "+parag.getText());

// processParagraphEx(parag, markCharacters, segmentationConditions, segmentationExceptions, presentation);
}
}
// }
}
}
}
}


}


I hope the shared information will be helpful.

Many Thanks,