Free Support Forum -

How to get size and color of text in slide

Hi Developer,

Can I ask a question,

we want to extract PPT text and show it in HTML. So we need get text size and color.
I have not found any method which can get text size. return value of portionFormat.getFontHeight() is NaN.
And when I tried to get color with portionFormat.getFillFormat().getSolidFillColor().getColor()
, it alaways give me rgb(0,0,0) even the color is blue.

Can you please help on this.


Hi Stone,

Thank you for inquiring Aspose.Slides.

I have observed your requirements and have worked over them. Please try using following sample code on your end to serve the purpose.

//Create an instance of Presentation class
Presentation pres = new Presentation();

//Get reference of a slide
ISlide slide = pres.getSlides().get_Item(0);
//Add an AutoShape of Rectangle type
IAutoShape ashp = slide.getShapes().addAutoShape(ShapeType.Rectangle, 150, 75, 400, 300);
//Add TextFrame to the Rectangle
ashp.addTextFrame(“Aspose TextBox”);
IPortion port = ashp.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0);
IPortionFormat pf = port.getPortionFormat();


I hope this will be helpful. Please share if I may help you further in this regard.

Best Regards,

Where pf is IPortionFormat, We tried the following to get the color of Blue coloured Text. All of them are returning rbg(0,0,0)

pf.getFontHeight() is returning Nan.

Also, Please note that, We just need to read the PPT slides that we get as input and get the font size and color of the text. We should NOT set and get the colors and font height as you have given in the sample code above.

Please advise.

Hi Stone,

I have observed your comments and like to request you to please try using following sample code on your end to serve the purpose.

Presentation pres = new Presentation(“D://test.pptx”);
for (ISlide slide : pres.getSlides()) {
for (IShape shp : slide.getShapes())
if (shp.getPlaceholder()!= null) {
for (IParagraph paragraph : ((IAutoShape) shp)
.getTextFrame().getParagraphs()) {
for (IPortion portion : paragraph.getPortions()) {
if ((portion.getText().length()!=0)){
System.out.println("PTEXT: " + portion.getText());
System.out.println("FontHeight: "+ portion.createPortionFormatEffective().getFontHeight());
if (portion.getPortionFormat().getLatinFont() != null)
System.out.println("FontNameLatin: “+ portion.getPortionFormat().getLatinFont().getFontName());
System.out.println(” Fill Color: “+ portion.createPortionFormatEffective().getFillFormat().getSolidFillColor().toString());
System.out.println(” Highlight Color: “+ portion.createPortionFormatEffective().getHighlightColor().toString());
System.out.println(” Back Color: “+ portion.createPortionFormatEffective().getFillFormat().getPatternFormat().getBackColor().toString());
System.out.println(” Fore Color: "+ portion.createPortionFormatEffective().getFillFormat().getPatternFormat().getForeColor().toString());

I hope this will be helpful. Please share if I may help you further in this regard.

Best Regards,

Hi Adnan,




Best Regards,

Hi Stone,

Thanks for your valuable feedback.We are glad to hear that, things have started working at your end.

Please feel free to contact us if we can be of any help to you.

Best Regards,