asposeslidesjava 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/asposeslidesjava.gemspec +27 -0
- data/config/aspose.yml +5 -0
- data/data/Aspose.html +55 -0
- data/data/Aspose.pptx +0 -0
- data/data/AsposeChart.pptx +0 -0
- data/data/Bass-Drum.wav +0 -0
- data/data/HelloWorld.pptx +0 -0
- data/data/Presentation1.ppt +0 -0
- data/data/Shapes/OleEmbed.pptx +0 -0
- data/data/Shapes/Wildlife.mp4 +0 -0
- data/data/Shapes/sample.xlsx +0 -0
- data/data/Source.odp +0 -0
- data/data/Tables/aspose-logo.jpg +0 -0
- data/data/Tables/demotable.pptx +0 -0
- data/data/Text/Welcome.pptx +0 -0
- data/data/Text/import.html +119 -0
- data/data/Text/input.pptx +0 -0
- data/data/Wildlife.mp4 +0 -0
- data/data/WithActiveX.pptm +0 -0
- data/data/aspose-logo.jpg +0 -0
- data/data/demo.pptx +0 -0
- data/data/night.jpg +0 -0
- data/data/vbamacro.pptx +0 -0
- data/lib/asposeslidesjava.rb +71 -0
- data/lib/asposeslidesjava/ActiveX/addactivex.rb +21 -0
- data/lib/asposeslidesjava/Charts/chartlegend.rb +33 -0
- data/lib/asposeslidesjava/Charts/chartproperties.rb +120 -0
- data/lib/asposeslidesjava/Charts/chartseries.rb +28 -0
- data/lib/asposeslidesjava/Charts/charttrendlines.rb +53 -0
- data/lib/asposeslidesjava/Charts/createchart.rb +163 -0
- data/lib/asposeslidesjava/Charts/errorbars.rb +84 -0
- data/lib/asposeslidesjava/Charts/existingchart.rb +66 -0
- data/lib/asposeslidesjava/Charts/formattingchartentities.rb +163 -0
- data/lib/asposeslidesjava/Charts/setlabeldistance.rb +24 -0
- data/lib/asposeslidesjava/Charts/setpiechartcolors.rb +118 -0
- data/lib/asposeslidesjava/Presentation/convertingtohtml.rb +25 -0
- data/lib/asposeslidesjava/Presentation/convertingtonotes.rb +37 -0
- data/lib/asposeslidesjava/Presentation/convertingtopdf.rb +16 -0
- data/lib/asposeslidesjava/Presentation/convertingtotiff.rb +62 -0
- data/lib/asposeslidesjava/Presentation/convertingtoxps.rb +43 -0
- data/lib/asposeslidesjava/Presentation/odptopptx.rb +16 -0
- data/lib/asposeslidesjava/Presentation/ppttopptx.rb +16 -0
- data/lib/asposeslidesjava/Presentation/properties.rb +106 -0
- data/lib/asposeslidesjava/Presentation/zoom.rb +20 -0
- data/lib/asposeslidesjava/Shapes/addellipseshape.rb +60 -0
- data/lib/asposeslidesjava/Shapes/addinglineshape.rb +65 -0
- data/lib/asposeslidesjava/Shapes/addrectangleshape.rb +58 -0
- data/lib/asposeslidesjava/Shapes/cloneshape.rb +32 -0
- data/lib/asposeslidesjava/Shapes/connectshapes.rb +83 -0
- data/lib/asposeslidesjava/Shapes/embedvideo.rb +32 -0
- data/lib/asposeslidesjava/Shapes/fillingshapes.rb +98 -0
- data/lib/asposeslidesjava/Shapes/findshape.rb +30 -0
- data/lib/asposeslidesjava/Shapes/formatlines.rb +99 -0
- data/lib/asposeslidesjava/Shapes/frame.rb +85 -0
- data/lib/asposeslidesjava/Shapes/groupshape.rb +35 -0
- data/lib/asposeslidesjava/Shapes/oleobject.rb +26 -0
- data/lib/asposeslidesjava/Shapes/rotatingshapes.rb +25 -0
- data/lib/asposeslidesjava/Shapes/shapeproperties.rb +30 -0
- data/lib/asposeslidesjava/Shapes/shapethumbnail.rb +18 -0
- data/lib/asposeslidesjava/Slides/accessslides.rb +38 -0
- data/lib/asposeslidesjava/Slides/addslides.rb +28 -0
- data/lib/asposeslidesjava/Slides/background.rb +76 -0
- data/lib/asposeslidesjava/Slides/changingposition.rb +22 -0
- data/lib/asposeslidesjava/Slides/cloneslides.rb +72 -0
- data/lib/asposeslidesjava/Slides/creatingsvg.rb +27 -0
- data/lib/asposeslidesjava/Slides/hyperlinks.rb +19 -0
- data/lib/asposeslidesjava/Slides/removeslides.rb +46 -0
- data/lib/asposeslidesjava/Slides/sizeandlayout.rb +55 -0
- data/lib/asposeslidesjava/Slides/thumbnail.rb +113 -0
- data/lib/asposeslidesjava/Slides/transitions.rb +24 -0
- data/lib/asposeslidesjava/SmartArt/addsmartart.rb +26 -0
- data/lib/asposeslidesjava/SmartArt/fillformat.rb +28 -0
- data/lib/asposeslidesjava/Tables/addimage.rb +34 -0
- data/lib/asposeslidesjava/Tables/aligntext.rb +48 -0
- data/lib/asposeslidesjava/Tables/clonerowcolumn.rb +76 -0
- data/lib/asposeslidesjava/Tables/createtable.rb +61 -0
- data/lib/asposeslidesjava/Tables/removerowcolumn.rb +27 -0
- data/lib/asposeslidesjava/Text/createtextbox.rb +79 -0
- data/lib/asposeslidesjava/Text/exporttexttohtml.rb +30 -0
- data/lib/asposeslidesjava/Text/importhtml.rb +51 -0
- data/lib/asposeslidesjava/Text/managefont.rb +30 -0
- data/lib/asposeslidesjava/Text/managetext.rb +128 -0
- data/lib/asposeslidesjava/Text/paragraphs.rb +260 -0
- data/lib/asposeslidesjava/Text/replacetext.rb +23 -0
- data/lib/asposeslidesjava/Text/shadoweffects.rb +37 -0
- data/lib/asposeslidesjava/Text/textfont.rb +130 -0
- data/lib/asposeslidesjava/Text/wordart.rb +45 -0
- data/lib/asposeslidesjava/VBAMacros/removevbamacro.rb +18 -0
- data/lib/asposeslidesjava/activex.rb +1 -0
- data/lib/asposeslidesjava/asposeslides.rb +10 -0
- data/lib/asposeslidesjava/charts.rb +9 -0
- data/lib/asposeslidesjava/helloworld.rb +38 -0
- data/lib/asposeslidesjava/presentation.rb +9 -0
- data/lib/asposeslidesjava/shapes.rb +15 -0
- data/lib/asposeslidesjava/slides.rb +11 -0
- data/lib/asposeslidesjava/smartart.rb +2 -0
- data/lib/asposeslidesjava/tables.rb +5 -0
- data/lib/asposeslidesjava/text.rb +10 -0
- data/lib/asposeslidesjava/vbamacros.rb +1 -0
- data/lib/asposeslidesjava/version.rb +3 -0
- data/samples/test.rb +8 -0
- metadata +206 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
module Asposeslidesjava
|
2
|
+
module SizeAndLayout
|
3
|
+
def initialize()
|
4
|
+
# Setting the Size and Type of a slide
|
5
|
+
set_size_and_type()
|
6
|
+
|
7
|
+
# Setting the page size when generating PDF
|
8
|
+
set_page_size_for_pdf()
|
9
|
+
end
|
10
|
+
|
11
|
+
def set_size_and_type()
|
12
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
13
|
+
|
14
|
+
# Instantiate Presentation class that represents the presentation file
|
15
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'demo.pptx')
|
16
|
+
aux_pres = Rjb::import('com.aspose.slides.Presentation').new
|
17
|
+
|
18
|
+
slide = pres.getSlides().get_Item(0)
|
19
|
+
|
20
|
+
# Set the slide size of generated presentations to that of source
|
21
|
+
aux_pres.getSlideSize().setType(pres.getSlideSize().getType())
|
22
|
+
aux_pres.getSlideSize().setSize(pres.getSlideSize().getSize())
|
23
|
+
|
24
|
+
# Clone required slide
|
25
|
+
aux_pres.getSlides().addClone(pres.getSlides().get_Item(0))
|
26
|
+
aux_pres.getSlides().removeAt(0)
|
27
|
+
|
28
|
+
# Saving the presentation
|
29
|
+
save_format = Rjb::import('com.aspose.slides.SaveFormat')
|
30
|
+
pres.save(data_dir + "Slide_Size_Type.pptx", save_format.Pptx)
|
31
|
+
|
32
|
+
puts "Set slide size and type, please check the output file."
|
33
|
+
end
|
34
|
+
|
35
|
+
def set_page_size_for_pdf()
|
36
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
37
|
+
|
38
|
+
# Instantiate Presentation class that represents the presentation file
|
39
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
40
|
+
|
41
|
+
# Set SlideSize.Type Property
|
42
|
+
pres.getSlideSize().setType(Rjb::import('com.aspose.slides.SlideSizeType').A4Paper)
|
43
|
+
|
44
|
+
# Set different properties of PDF Options
|
45
|
+
opts = Rjb::import('com.aspose.slides.PdfOptions').new
|
46
|
+
opts.setSufficientResolution(600)
|
47
|
+
|
48
|
+
# Saving the presentation
|
49
|
+
save_format = Rjb::import('com.aspose.slides.SaveFormat')
|
50
|
+
pres.save(data_dir + "Export.pdf", save_format.Pdf, opts)
|
51
|
+
|
52
|
+
puts "Set page size for pdf, please check the output file."
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
module Asposeslidesjava
|
2
|
+
module Thumbnail
|
3
|
+
def initialize()
|
4
|
+
# Generating a Thumbnail from a Slide
|
5
|
+
create_thumbnail()
|
6
|
+
|
7
|
+
# Generating a Thumbnail from a Slide with User Defined Dimensions
|
8
|
+
create_thumbnail_custom_size()
|
9
|
+
|
10
|
+
# Generating a Thumbnail from a Slide in Notes Slides View
|
11
|
+
create_thumbnail_in_notes_slides_view()
|
12
|
+
|
13
|
+
# Generating a Thumbnail of User Defined Window from a Slide
|
14
|
+
create_thumbnail_of_user_defined_window()
|
15
|
+
end
|
16
|
+
|
17
|
+
# Generating a Thumbnail from a Slide
|
18
|
+
def create_thumbnail()
|
19
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
20
|
+
|
21
|
+
# Instantiate Presentation class that represents the presentation file
|
22
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'demo.pptx')
|
23
|
+
|
24
|
+
# Access the first slide
|
25
|
+
slide = pres.getSlides().get_Item(0)
|
26
|
+
|
27
|
+
# Create a full scale image
|
28
|
+
image = slide.getThumbnail()
|
29
|
+
|
30
|
+
# Save the image to disk in JPEG format
|
31
|
+
Rjb::import('javax.imageio.ImageIO').write(image, "jpeg", Rjb::import('java.io.File').new(data_dir + "ContentBG_tnail.jpg"))
|
32
|
+
|
33
|
+
puts "Created thumbnail, please check the output file."
|
34
|
+
end
|
35
|
+
|
36
|
+
# Generating a Thumbnail from a Slide with User Defined Dimensions
|
37
|
+
def create_thumbnail_custom_size()
|
38
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
39
|
+
|
40
|
+
# Instantiate Presentation class that represents the presentation file
|
41
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'demo.pptx')
|
42
|
+
|
43
|
+
# Access the first slide
|
44
|
+
slide = pres.getSlides().get_Item(0)
|
45
|
+
|
46
|
+
# User defined dimension
|
47
|
+
desired_x = 1200
|
48
|
+
desired_y = 800
|
49
|
+
|
50
|
+
# Getting scaled value of X and Y
|
51
|
+
scale_x = (1.0 / pres.getSlideSize().getSize().getWidth()) * desired_x
|
52
|
+
scale_y = (1.0 / pres.getSlideSize().getSize().getHeight()) * desired_y
|
53
|
+
|
54
|
+
# Create a full scale image
|
55
|
+
image = slide.getThumbnail(scale_x, scale_y)
|
56
|
+
|
57
|
+
# Save the image to disk in JPEG format
|
58
|
+
Rjb::import('javax.imageio.ImageIO').write(image, "jpeg", Rjb::import('java.io.File').new(data_dir + "ContentBG_tnail.jpg"))
|
59
|
+
|
60
|
+
puts "Created thumbnail with custom size, please check the output file."
|
61
|
+
end
|
62
|
+
|
63
|
+
# Generating a Thumbnail from a Slide in Notes Slides View
|
64
|
+
def create_thumbnail_in_notes_slides_view()
|
65
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
66
|
+
|
67
|
+
# Instantiate Presentation class that represents the presentation file
|
68
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'demo.pptx')
|
69
|
+
|
70
|
+
# Access the first slide
|
71
|
+
slide = pres.getSlides().get_Item(0)
|
72
|
+
|
73
|
+
# User defined dimension
|
74
|
+
desired_x = 1200
|
75
|
+
desired_y = 800
|
76
|
+
|
77
|
+
# Getting scaled value of X and Y
|
78
|
+
scale_x = (1.0 / pres.getSlideSize().getSize().getWidth()) * desired_x
|
79
|
+
scale_y = (1.0 / pres.getSlideSize().getSize().getHeight()) * desired_y
|
80
|
+
|
81
|
+
# Create a full scale image
|
82
|
+
image = slide.getNotesSlide().getThumbnail(scale_x, scale_y)
|
83
|
+
|
84
|
+
# Save the image to disk in JPEG format
|
85
|
+
Rjb::import('javax.imageio.ImageIO').write(image, "jpeg", Rjb::import('java.io.File').new(data_dir + "ContentBG_tnail.jpg"))
|
86
|
+
|
87
|
+
puts "Created thumbnail in notes slides view, please check the output file."
|
88
|
+
end
|
89
|
+
|
90
|
+
# Generating a Thumbnail of User Defined Window from a Slide
|
91
|
+
def create_thumbnail_of_user_defined_window()
|
92
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
93
|
+
|
94
|
+
# Instantiate Presentation class that represents the presentation file
|
95
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'demo.pptx')
|
96
|
+
|
97
|
+
# Access the first slide
|
98
|
+
slide = pres.getSlides().get_Item(0)
|
99
|
+
|
100
|
+
# Create a full scale image
|
101
|
+
image = slide.getThumbnail(1,1)
|
102
|
+
|
103
|
+
# Getting the image of desired window inside generated slide thumnbnail
|
104
|
+
# BufferedImage window = image.getSubimage(windowX, windowY, windowsWidth, windowHeight);
|
105
|
+
window_image = image.getSubimage(100, 100, 200, 200)
|
106
|
+
|
107
|
+
# Save the image to disk in JPEG format
|
108
|
+
Rjb::import('javax.imageio.ImageIO').write(image, "jpeg", Rjb::import('java.io.File').new(data_dir + "ContentBG_tnail.jpg"))
|
109
|
+
|
110
|
+
puts "Created thumbnail of user defined window, please check the output file."
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Asposeslidesjava
|
2
|
+
module Transitions
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Instantiate Presentation class that represents the presentation file
|
7
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'demo.pptx')
|
8
|
+
|
9
|
+
transition_type = Rjb::import('com.aspose.slides.TransitionType')
|
10
|
+
|
11
|
+
# Apply circle type transition on slide 1
|
12
|
+
pres.getSlides().get_Item(0).getSlideShowTransition().setType(transition_type.Circle)
|
13
|
+
|
14
|
+
# Apply comb type transition on slide 2
|
15
|
+
pres.getSlides().get_Item(1).getSlideShowTransition().setType(transition_type.Comb)
|
16
|
+
|
17
|
+
# Saving the presentation
|
18
|
+
save_format = Rjb::import('com.aspose.slides.SaveFormat')
|
19
|
+
pres.save(data_dir + "SimpleTransition.pptx", save_format.Pptx)
|
20
|
+
|
21
|
+
puts "Done with simple transition, please check the output file."
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Asposeslidesjava
|
2
|
+
module AddSmartArt
|
3
|
+
def initialize()
|
4
|
+
# Creating a SmartArt Shape
|
5
|
+
create_smartart_shape()
|
6
|
+
end
|
7
|
+
|
8
|
+
def create_smartart_shape()
|
9
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
10
|
+
|
11
|
+
# Create an instance of Presentation class
|
12
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
13
|
+
|
14
|
+
# Get the first slide
|
15
|
+
slide = pres.getSlides().get_Item(0)
|
16
|
+
|
17
|
+
# Add Smart Art Shape
|
18
|
+
smart = slide.getShapes().addSmartArt(0, 0, 400, 400, Rjb::import('com.aspose.slides.SmartArtLayoutType').BasicBlockList)
|
19
|
+
|
20
|
+
# Write the presentation as a PPTX file
|
21
|
+
pres.save(data_dir + "SimpleSmartArt.pptx", Rjb::import('com.aspose.slides.SaveFormat').Pptx)
|
22
|
+
|
23
|
+
puts "Created smartart shape, please check the output file."
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Asposeslidesjava
|
2
|
+
module FillFormat
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Create an instance of Presentation class
|
7
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
8
|
+
|
9
|
+
# Get the first slide
|
10
|
+
slide = pres.getSlides().get_Item(0)
|
11
|
+
|
12
|
+
# Adding SmartArt shape and nodes
|
13
|
+
chevron = slide.getShapes().addSmartArt(10, 10, 800, 60, Rjb::import('com.aspose.slides.SmartArtLayoutType').ClosedChevronProcess)
|
14
|
+
node = chevron.getAllNodes().addNode()
|
15
|
+
node.getTextFrame().setText("Some text")
|
16
|
+
|
17
|
+
# Setting node fill color
|
18
|
+
item = node.getShapes().get_Item(0)
|
19
|
+
item.getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
|
20
|
+
item.getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').RED)
|
21
|
+
|
22
|
+
# Write the presentation as a PPTX file
|
23
|
+
pres.save(data_dir + "FillFormat.pptx", Rjb::import('com.aspose.slides.SaveFormat').Pptx)
|
24
|
+
|
25
|
+
puts "Set fill format for smartart node, please check the output file."
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Asposeslidesjava
|
2
|
+
module AddImage
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Tables/'
|
5
|
+
|
6
|
+
# Create an instance of Presentation class
|
7
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
8
|
+
|
9
|
+
# Get the first slide
|
10
|
+
sld = pres.getSlides().get_Item(0)
|
11
|
+
|
12
|
+
# Define columns with widths and rows with heights
|
13
|
+
dbl_cols = [150,150,150,150]
|
14
|
+
dbl_rows = [100,100,100,100,90]
|
15
|
+
|
16
|
+
# Add table shape to slide
|
17
|
+
tbl = sld.getShapes().addTable(50, 50, dbl_cols, dbl_rows)
|
18
|
+
|
19
|
+
# Creating a Buffered Image object to hold the image file
|
20
|
+
image = Rjb::import('javax.imageio.ImageIO').read(Rjb::import('java.io.File').new(data_dir + "aspose-logo.jpg"))
|
21
|
+
imgx1 = pres.getImages().addImage(image)
|
22
|
+
|
23
|
+
tbl.get_Item(0,0).getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Picture)
|
24
|
+
tbl.get_Item(0,0).getFillFormat().getPictureFillFormat().setPictureFillMode(Rjb::import('com.aspose.slides.PictureFillMode').Stretch)
|
25
|
+
tbl.get_Item(0,0).getFillFormat().getPictureFillFormat().getPicture().setImage(imgx1)
|
26
|
+
|
27
|
+
# Write the presentation as a PPTX file
|
28
|
+
save_format = Rjb::import('com.aspose.slides.SaveFormat')
|
29
|
+
pres.save(data_dir + "AddImage.pptx", save_format.Pptx)
|
30
|
+
|
31
|
+
puts "Added image, please check the output file."
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Asposeslidesjava
|
2
|
+
module AlignText
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Tables/'
|
5
|
+
|
6
|
+
# Create an instance of Presentation class
|
7
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
8
|
+
|
9
|
+
# Get the first slide
|
10
|
+
slide = pres.getSlides().get_Item(0)
|
11
|
+
|
12
|
+
# Define columns with widths and rows with heights
|
13
|
+
dbl_cols = [120, 120, 120, 120]
|
14
|
+
dbl_rows = [100, 100, 100, 100]
|
15
|
+
|
16
|
+
# Add table shape to slide
|
17
|
+
tbl = slide.getShapes().addTable(100, 50, dbl_cols, dbl_rows)
|
18
|
+
|
19
|
+
# Add text to the merged cell
|
20
|
+
tbl.getRows().get_Item(0).get_Item(1).getTextFrame().setText("10")
|
21
|
+
tbl.getRows().get_Item(0).get_Item(2).getTextFrame().setText("20")
|
22
|
+
tbl.getRows().get_Item(0).get_Item(3).getTextFrame().setText("30")
|
23
|
+
|
24
|
+
# Accessing the text frame
|
25
|
+
txt_frame = tbl.getRows().get_Item(0).get_Item(0).getTextFrame()
|
26
|
+
|
27
|
+
# Create the Paragraph object for text frame
|
28
|
+
para = txt_frame.getParagraphs().get_Item(0)
|
29
|
+
|
30
|
+
# Create Portion object for paragraph
|
31
|
+
portion = para.getPortions().get_Item(0)
|
32
|
+
portion.setText("Text here")
|
33
|
+
portion.getPortionFormat().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
|
34
|
+
portion.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').BLACK)
|
35
|
+
|
36
|
+
# Aligning the text vertically
|
37
|
+
cell = tbl.getRows().get_Item(0).get_Item(0)
|
38
|
+
cell.setTextAnchorType(Rjb::import('com.aspose.slides.TextAnchorType').Center)
|
39
|
+
cell.setTextVerticalType(Rjb::import('com.aspose.slides.TextVerticalType').Vertical270)
|
40
|
+
|
41
|
+
# Write the presentation as a PPTX file
|
42
|
+
save_format = Rjb::import('com.aspose.slides.SaveFormat')
|
43
|
+
pres.save(data_dir + "AlignText.pptx", save_format.Pptx)
|
44
|
+
|
45
|
+
puts "Aligned Text, please check the output file."
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Asposeslidesjava
|
2
|
+
module CloneRowColumn
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Tables/'
|
5
|
+
|
6
|
+
# Create an instance of Presentation class
|
7
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
8
|
+
|
9
|
+
# Get the first slide
|
10
|
+
sld = pres.getSlides().get_Item(0)
|
11
|
+
|
12
|
+
# Define columns with widths and rows with heights
|
13
|
+
dbl_cols = [50, 50, 50]
|
14
|
+
dbl_rows = [50, 30, 30, 30]
|
15
|
+
|
16
|
+
# Add table shape to slide
|
17
|
+
tbl = sld.getShapes().addTable(100, 50, dbl_cols, dbl_rows)
|
18
|
+
|
19
|
+
fill_type = Rjb::import('com.aspose.slides.FillType')
|
20
|
+
color = Rjb::import('java.awt.Color')
|
21
|
+
|
22
|
+
# Set border format for each cell
|
23
|
+
row = 0
|
24
|
+
while row < tbl.getRows().size()
|
25
|
+
cell = 0
|
26
|
+
while cell < tbl.getRows().get_Item(row).size()
|
27
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().getFillFormat().setFillType(fill_type.Solid)
|
28
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().getFillFormat().getSolidFillColor().setColor(color.RED)
|
29
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().setWidth(5)
|
30
|
+
|
31
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().getFillFormat().setFillType(fill_type.Solid)
|
32
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().getFillFormat().getSolidFillColor().setColor(color.RED)
|
33
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().setWidth(5)
|
34
|
+
|
35
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().getFillFormat().setFillType(fill_type.Solid)
|
36
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().getFillFormat().getSolidFillColor().setColor(color.RED)
|
37
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().setWidth(5)
|
38
|
+
|
39
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().getFillFormat().setFillType(fill_type.Solid)
|
40
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().getFillFormat().getSolidFillColor().setColor(color.RED)
|
41
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().setWidth(5)
|
42
|
+
|
43
|
+
cell +=1
|
44
|
+
end
|
45
|
+
row +=1
|
46
|
+
end
|
47
|
+
|
48
|
+
tbl.getColumns().get_Item(0).get_Item(0).getTextFrame().setText("00")
|
49
|
+
tbl.getColumns().get_Item(0).get_Item(1).getTextFrame().setText("01")
|
50
|
+
tbl.getColumns().get_Item(0).get_Item(2).getTextFrame().setText("02")
|
51
|
+
tbl.getColumns().get_Item(0).get_Item(3).getTextFrame().setText("03")
|
52
|
+
tbl.getColumns().get_Item(1).get_Item(0).getTextFrame().setText("10")
|
53
|
+
tbl.getColumns().get_Item(2).get_Item(0).getTextFrame().setText("20")
|
54
|
+
tbl.getColumns().get_Item(1).get_Item(1).getTextFrame().setText("11")
|
55
|
+
tbl.getColumns().get_Item(2).get_Item(1).getTextFrame().setText("21")
|
56
|
+
|
57
|
+
# AddClone adds a row in the end of the table
|
58
|
+
tbl.getRows().addClone(tbl.getRows().get_Item(0) , false)
|
59
|
+
|
60
|
+
# AddClone adds a column in the end of the table
|
61
|
+
tbl.getColumns().addClone(tbl.getColumns().get_Item(0), false)
|
62
|
+
|
63
|
+
# InsertClone adds a row at specific position in a table
|
64
|
+
tbl.getRows().insertClone(2, tbl.getRows().get_Item(0), false)
|
65
|
+
|
66
|
+
# InsertClone adds a row at specific position in a table
|
67
|
+
tbl.getColumns().insertClone(2, tbl.getColumns().get_Item(0), false)
|
68
|
+
|
69
|
+
# Write the presentation as a PPTX file
|
70
|
+
save_format = Rjb::import('com.aspose.slides.SaveFormat')
|
71
|
+
pres.save(data_dir + "CloneRowColumn.pptx", save_format.Pptx)
|
72
|
+
|
73
|
+
puts "Cloned Row & Column from table, please check the output file."
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Asposeslidesjava
|
2
|
+
module CreateTable
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Tables/'
|
5
|
+
|
6
|
+
# Create an instance of Presentation class
|
7
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
8
|
+
|
9
|
+
# Get the first slide
|
10
|
+
sld = pres.getSlides().get_Item(0)
|
11
|
+
|
12
|
+
# Define columns with widths and rows with heights
|
13
|
+
dblCols = [50, 50, 50]
|
14
|
+
dblRows = [50, 30, 30, 30, 30]
|
15
|
+
|
16
|
+
# Add table shape to slide
|
17
|
+
tbl = sld.getShapes().addTable(100, 50, dblCols, dblRows)
|
18
|
+
|
19
|
+
fill_type = Rjb::import('com.aspose.slides.FillType')
|
20
|
+
color = Rjb::import('java.awt.Color')
|
21
|
+
|
22
|
+
# Set border format for each cell
|
23
|
+
row = 0
|
24
|
+
while row < tbl.getRows().size()
|
25
|
+
cell = 0
|
26
|
+
while cell < tbl.getRows().get_Item(row).size()
|
27
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().getFillFormat().setFillType(fill_type.Solid)
|
28
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().getFillFormat().getSolidFillColor().setColor(color.RED)
|
29
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderTop().setWidth(5)
|
30
|
+
|
31
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().getFillFormat().setFillType(fill_type.Solid)
|
32
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().getFillFormat().getSolidFillColor().setColor(color.RED)
|
33
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderBottom().setWidth(5)
|
34
|
+
|
35
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().getFillFormat().setFillType(fill_type.Solid)
|
36
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().getFillFormat().getSolidFillColor().setColor(color.RED)
|
37
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderLeft().setWidth(5)
|
38
|
+
|
39
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().getFillFormat().setFillType(fill_type.Solid)
|
40
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().getFillFormat().getSolidFillColor().setColor(color.RED)
|
41
|
+
tbl.getRows().get_Item(row).get_Item(cell).getBorderRight().setWidth(5)
|
42
|
+
|
43
|
+
cell +=1
|
44
|
+
end
|
45
|
+
row +=1
|
46
|
+
end
|
47
|
+
|
48
|
+
# Merge cells 1 & 2 of row 1
|
49
|
+
tbl.mergeCells(tbl.getRows().get_Item(0).get_Item(0), tbl.getRows().get_Item(1).get_Item(0), false)
|
50
|
+
|
51
|
+
# Add text to the merged cell
|
52
|
+
tbl.getRows().get_Item(0).get_Item(0).getTextFrame().setText("Merged Cells")
|
53
|
+
|
54
|
+
# Write the presentation as a PPTX file
|
55
|
+
save_format = Rjb::import('com.aspose.slides.SaveFormat')
|
56
|
+
pres.save(data_dir + "CreateTable.pptx", save_format.Pptx)
|
57
|
+
|
58
|
+
puts "Created table, please check the output file."
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|