module Asposeslidesjava::CreateTextBox

Public Class Methods

new() click to toggle source
# File lib/asposeslidesjava/Text/createtextbox.rb, line 3
def initialize()
    # Creating a TextBox on Slide
    create_textbox()

    # Creating a TextBox with Hyperlink
    create_textbox_with_hyperlink()
end

Public Instance Methods

create_textbox() click to toggle source
# File lib/asposeslidesjava/Text/createtextbox.rb, line 11
def create_textbox()
    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
    shp = sld.getShapes().addAutoShape(Rjb::import('com.aspose.slides.ShapeType').Rectangle, 150, 75, 150, 50)

    # Add TextFrame to the Rectangle
    shp.addTextFrame(" ")

    # Accessing the text frame
    txt_frame = shp.getTextFrame()

    # Create the Paragraph object for text frame
    para = txt_frame.getParagraphs().get_Item(0)

    # Create Portion object for paragraph
    portion = para.getPortions().get_Item(0)

    # Set Text
    portion.setText("Aspose TextBox")

    # Write the presentation as a PPTX file
    save_format = Rjb::import('com.aspose.slides.SaveFormat')
    pres.save(data_dir + "TextBox.pptx", save_format.Pptx)

    puts "Created TextBox, please check the output file."
end