Module: Asposeslidesjava::ManageText

Defined in:
lib/asposeslidesjava/Text/managetext.rb

Instance Method Summary collapse

Instance Method Details

#initializeObject



3
4
5
6
7
8
9
10
11
12
# File 'lib/asposeslidesjava/Text/managetext.rb', line 3

def initialize()
    # Setting the AutofitType property of text frame 
    set_autofittype_of_text()

    # Setting the anchor of TextFrame 
    set_anchor_of_text()

    # Rotating the text 
    rotate_text()
end

#rotate_textObject



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/asposeslidesjava/Text/managetext.rb', line 90

def rotate_text()
    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
    slide = pres.getSlides().get_Item(0)

    # Add an AutoShape of Rectangle type
    ashp = slide.getShapes().addAutoShape(Rjb::import('com.aspose.slides.ShapeType').Rectangle, 150, 75, 350, 350)

    # Add TextFrame to the Rectangle
    ashp.addTextFrame(" ")
    ashp.getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').NoFill)

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

    # Setting text Vertical type
    txt_frame.getTextFrameFormat().setTextVerticalType(Rjb::import('com.aspose.slides.TextVerticalType').Vertical270)

    # 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)
    portion.setText("A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog.")
    portion.getPortionFormat().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
    portion.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').BLACK)

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

    puts "Done with text rotation, please check the output file."
end

#set_anchor_of_textObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/asposeslidesjava/Text/managetext.rb', line 52

def set_anchor_of_text()
    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
    slide = pres.getSlides().get_Item(0)

    # Add an AutoShape of Rectangle type
    ashp = slide.getShapes().addAutoShape(Rjb::import('com.aspose.slides.ShapeType').Rectangle, 150, 75, 350, 350)

    # Add TextFrame to the Rectangle
    ashp.addTextFrame(" ")
    ashp.getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').NoFill)

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

    # Setting text anchoring to bottom
    txt_frame.getTextFrameFormat().setAnchoringType(Rjb::import('com.aspose.slides.TextAnchorType').Bottom)

    # 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)
    portion.setText("A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog.")
    portion.getPortionFormat().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
    portion.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').BLACK)

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

    puts "Set anchor of text, please check the output file."
end

#set_autofittype_of_textObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/asposeslidesjava/Text/managetext.rb', line 14

def set_autofittype_of_text()
    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
    slide = pres.getSlides().get_Item(0)

    # Add an AutoShape of Rectangle type
    ashp = slide.getShapes().addAutoShape(Rjb::import('com.aspose.slides.ShapeType').Rectangle, 150, 75, 350, 350)

    # Add TextFrame to the Rectangle
    ashp.addTextFrame(" ")
    ashp.getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').NoFill)

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

    # Setting text autofit type
    txt_frame.getTextFrameFormat().setAutofitType(Rjb::import('com.aspose.slides.TextAutofitType').Shape)

    # 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)
    portion.setText("A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog.")
    portion.getPortionFormat().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
    portion.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').BLACK)

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

    puts "Set autofittype of text, please check the output file."
end