3
4
5
6
7
8
9
10
11
12
13
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
|
# File 'lib/asposeslidesjava/Tables/aligntext.rb', line 3
def initialize()
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Tables/'
pres = Rjb::import('com.aspose.slides.Presentation').new
slide = pres.getSlides().get_Item(0)
dbl_cols = [120, 120, 120, 120]
dbl_rows = [100, 100, 100, 100]
tbl = slide.getShapes().addTable(100, 50, dbl_cols, dbl_rows)
tbl.getRows().get_Item(0).get_Item(1).getTextFrame().setText("10")
tbl.getRows().get_Item(0).get_Item(2).getTextFrame().setText("20")
tbl.getRows().get_Item(0).get_Item(3).getTextFrame().setText("30")
txt_frame = tbl.getRows().get_Item(0).get_Item(0).getTextFrame()
para = txt_frame.getParagraphs().get_Item(0)
portion = para.getPortions().get_Item(0)
portion.setText("Text here")
portion.getPortionFormat().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
portion.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').BLACK)
cell = tbl.getRows().get_Item(0).get_Item(0)
cell.setTextAnchorType(Rjb::import('com.aspose.slides.TextAnchorType').Center)
cell.setTextVerticalType(Rjb::import('com.aspose.slides.TextVerticalType').Vertical270)
save_format = Rjb::import('com.aspose.slides.SaveFormat')
pres.save(data_dir + "AlignText.pptx", save_format.Pptx)
puts "Aligned Text, please check the output file."
end
|