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

Free Support Forum - aspose.com

Is there any way to list the fonts?

I’m using aspose slides .i need to get the fonts used in the document.can u give me a link so that i can refer??

Hi BharathKumar,


I have observed the requirements shared by you and suggest you to please try using the following sample code on your end serve the purpose. Please share, if I may help you further in this regard.

public static void GetFonts()
{
String path=“D:\Aspose Data\”;
PresentationEx pres = new PresentationEx(path+“portion-format-test.pptx”);

SlidesEx slides = pres.getSlides();

SlideEx slide = pres.getSlides().get_Item(0);

for (int i = 0; i < slides.getCount(); i++)
{
slide = slides.get_Item(i);
for (int j = 0; j < slide.getShapes().getCount(); j++)
{
ShapeEx shape = slide.getShapes().get_Item(j);
// if (shape.getPlaceholder() != null)
if (((AutoShapeEx)shape).getTextFrame() != null)
{
System.out.println(((AutoShapeEx) shape).getTextFrame().getText());
TextFrameEx tf2 = ((AutoShapeEx) shape).getTextFrame();
for (int k = 0; k < tf2.getParagraphs().getCount(); k++)
{
ParagraphEx paragraph = tf2.getParagraphs().get_Item(k);
for (int n = 0; n < paragraph.getPortions().getCount(); n++)
{
PortionEx portion = paragraph.getPortions().get_Item(n);
if(portion.getLatinFont()!=null)
System.out.println(portion.getLatinFont().getFontName());
if(portion.getEastAsianFont()!=null)
System.out.println(portion.getEastAsianFont().getFontName());
if(portion.getSymbolFont()!=null)
System.out.println(portion.getSymbolFont().getFontName());

if(portion.getComplexScriptFont()!=null)

System.out.println(portion.getComplexScriptFont().getFontName());
if(portion.getRawLatinFont()!=null)
System.out.println(portion.getRawLatinFont().getFontName());
if(portion.getRawEastAsianFont()!=null)
System.out.println(portion.getRawEastAsianFont().getFontName());
if(portion.getRawSymbolFont()!=null)
System.out.println(portion.getRawSymbolFont().getFontName());
if(portion.getRawComplexScriptFont()!=null)
System.out.println(portion.getRawComplexScriptFont().getFontName());

}

}
}

}
}
}

Many Thanks,