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

Free Support Forum - aspose.com

How to Add HTML Text to Slide and Set Font Style?

Hi Team,

Could you please help me with a sample code to

  • Insert a text box in a presentation
  • Add a html text to the text box with hyperlink
  • And the text for the hyperlink must be of font style Arial and size 8 pts.


Thank you for posting the inquiry.

To perform this sequence, you should add a rectangle autoshape, add an HTML text into a paragraph collection contained in an autoshape’s text frame, and set formatting options for the new paragraph. The following code snippet shows you how to do this:

// Add an empty transparent text box to a slide.
IAutoShape autoShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 20, 20, 200, 100);

// Add some HTML text to the shape.
String htmlData = "<a href=\"https://www.aspose.com/\">Aspose Website</a>";

// Set the text format for the HTML text.
IParagraph lastParagraph = autoShape.getTextFrame().getParagraphs().get_Item(0);
lastParagraph.getParagraphFormat().getDefaultPortionFormat().setLatinFont(new FontData("Arial"));

Manage TextBox
Manage Paragraph
Text Formatting

API Reference:
addAutoShape Method
addFromHtml Method
IParagraphFormat Interface

If you fail to do so, please share your example HTML text.