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
|
# File 'lib/asposeslidesjava/Tables/addimage.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
sld = pres.getSlides().get_Item(0)
dbl_cols = [150,150,150,150]
dbl_rows = [100,100,100,100,90]
tbl = sld.getShapes().addTable(50, 50, dbl_cols, dbl_rows)
image = Rjb::import('javax.imageio.ImageIO').read(Rjb::import('java.io.File').new(data_dir + "aspose-logo.jpg"))
imgx1 = pres.getImages().addImage(image)
tbl.get_Item(0,0).getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Picture)
tbl.get_Item(0,0).getFillFormat().getPictureFillFormat().setPictureFillMode(Rjb::import('com.aspose.slides.PictureFillMode').Stretch)
tbl.get_Item(0,0).getFillFormat().getPictureFillFormat().getPicture().setImage(imgx1)
save_format = Rjb::import('com.aspose.slides.SaveFormat')
pres.save(data_dir + "AddImage.pptx", save_format.Pptx)
puts "Added image, please check the output file."
end
|