Gan
Gan

Reputation: 644

How to set text font using Apache POI PPT API?

I am using Apache POI PPT API to create PPTX. I want to apply specific font family to text I have added in slide.

I have explore API and found only following method to specify color and font size, but no idea on how to set font family, Please help.

XSLFTextRun run1 = paragraph.addNewTextRun();
run1.setText("This is test"); 
run1.setFontColor(java.awt.Color.red);      
run1.setFontSize(24);    

Upvotes: 3

Views: 2150

Answers (1)

S.B
S.B

Reputation: 688

 XSLFTextRun run1 = p.addNewTextRun(); 
       run1.setText("This is test"); 
       run1.setFontFamily(HSSFFont.FONT_ARIAL);
       run1.setFontColor(Color.red);    
       run1.setFontSize(24);  

You can use the setFontFamily method to specify the font family

Upvotes: 5

Related Questions