Creating TextBox with Hyperlink in Ruby

To Create a TextBox with Hyperlink using Aspose.Slides Java for Ruby, call create_textbox_with_hyperlink method of CreateTextBox module. Here you can see example code.

Ruby Code

 def create_textbox_with_hyperlink()

    data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Text/'

    # Create an instance of Presentation class

    pres = Rjb::import('com.aspose.slides.Presentation').new

    # Get the first slide

    sld = pres.getSlides().get_Item(0)

    # Add autoshape of rectangle type

    pptxShape = sld.getShapes().addAutoShape(Rjb::import('com.aspose.slides.ShapeType').Rectangle, 150, 150, 150, 50)

    # Cast the shape to AutoShape

    pptxAutoShape = pptxShape

    # Access ITextFrame associated with the AutoShape


    text_frame = pptxAutoShape.getTextFrame()

    # Add some text to the frame


    #Set Hyperlink for the portion text

    hypman = text_frame.getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().getHyperlinkManager()


    # Write the presentation as a PPTX file

    save_format = Rjb::import('com.aspose.slides.SaveFormat') + "hLinkPPTX.pptx", save_format.Pptx)

    puts "Created TextBox with Hyperlink, please check the output file."


Download Running Code

Download Creating TextBox with Hyperlink (Aspose.Slides) from any of the below mentioned social coding sites: