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,27 @@
|
|
1
|
+
module Asposeslidesjava
|
2
|
+
module RemoveRowColumn
|
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
|
+
col_width = [100, 50, 30]
|
13
|
+
row_height = [30, 50, 30]
|
14
|
+
|
15
|
+
table = slide.getShapes().addTable(100, 100, col_width, row_height)
|
16
|
+
|
17
|
+
table.getRows().removeAt(1, false)
|
18
|
+
table.getColumns().removeAt(1, false)
|
19
|
+
|
20
|
+
# Write the presentation as a PPTX file
|
21
|
+
save_format = Rjb::import('com.aspose.slides.SaveFormat')
|
22
|
+
pres.save(data_dir + "RemoveRowColumn.pptx", save_format.Pptx)
|
23
|
+
|
24
|
+
puts "Removed Row & Column from table, please check the output file."
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Asposeslidesjava
|
2
|
+
module CreateTextBox
|
3
|
+
def initialize()
|
4
|
+
# Creating a TextBox on Slide
|
5
|
+
create_textbox()
|
6
|
+
|
7
|
+
# Creating a TextBox with Hyperlink
|
8
|
+
create_textbox_with_hyperlink()
|
9
|
+
end
|
10
|
+
|
11
|
+
def create_textbox()
|
12
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Text/'
|
13
|
+
|
14
|
+
# Create an instance of Presentation class
|
15
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
16
|
+
|
17
|
+
# Get the first slide
|
18
|
+
sld = pres.getSlides().get_Item(0)
|
19
|
+
|
20
|
+
# Add autoshape of rectangle type
|
21
|
+
shp = sld.getShapes().addAutoShape(Rjb::import('com.aspose.slides.ShapeType').Rectangle, 150, 75, 150, 50)
|
22
|
+
|
23
|
+
# Add TextFrame to the Rectangle
|
24
|
+
shp.addTextFrame(" ")
|
25
|
+
|
26
|
+
# Accessing the text frame
|
27
|
+
txt_frame = shp.getTextFrame()
|
28
|
+
|
29
|
+
# Create the Paragraph object for text frame
|
30
|
+
para = txt_frame.getParagraphs().get_Item(0)
|
31
|
+
|
32
|
+
# Create Portion object for paragraph
|
33
|
+
portion = para.getPortions().get_Item(0)
|
34
|
+
|
35
|
+
# Set Text
|
36
|
+
portion.setText("Aspose TextBox")
|
37
|
+
|
38
|
+
# Write the presentation as a PPTX file
|
39
|
+
save_format = Rjb::import('com.aspose.slides.SaveFormat')
|
40
|
+
pres.save(data_dir + "TextBox.pptx", save_format.Pptx)
|
41
|
+
|
42
|
+
puts "Created TextBox, please check the output file."
|
43
|
+
end
|
44
|
+
|
45
|
+
def create_textbox_with_hyperlink()
|
46
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Text/'
|
47
|
+
|
48
|
+
# Create an instance of Presentation class
|
49
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
50
|
+
|
51
|
+
# Get the first slide
|
52
|
+
sld = pres.getSlides().get_Item(0)
|
53
|
+
|
54
|
+
# Add autoshape of rectangle type
|
55
|
+
pptxShape = sld.getShapes().addAutoShape(Rjb::import('com.aspose.slides.ShapeType').Rectangle, 150, 150, 150, 50)
|
56
|
+
|
57
|
+
# Cast the shape to AutoShape
|
58
|
+
pptxAutoShape = pptxShape
|
59
|
+
|
60
|
+
# Access ITextFrame associated with the AutoShape
|
61
|
+
pptxAutoShape.addTextFrame("")
|
62
|
+
|
63
|
+
text_frame = pptxAutoShape.getTextFrame()
|
64
|
+
|
65
|
+
# Add some text to the frame
|
66
|
+
text_frame.getParagraphs().get_Item(0).getPortions().get_Item(0).setText("Aspose.Slides")
|
67
|
+
|
68
|
+
#Set Hyperlink for the portion text
|
69
|
+
hypman = text_frame.getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().getHyperlinkManager()
|
70
|
+
hypman.setExternalHyperlinkClick("http://www.aspose.com")
|
71
|
+
|
72
|
+
# Write the presentation as a PPTX file
|
73
|
+
save_format = Rjb::import('com.aspose.slides.SaveFormat')
|
74
|
+
pres.save(data_dir + "hLinkPPTX.pptx", save_format.Pptx)
|
75
|
+
|
76
|
+
puts "Created TextBox with Hyperlink, please check the output file."
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Asposeslidesjava
|
2
|
+
module ExportTextToHtml
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Text/'
|
5
|
+
|
6
|
+
# Create an instance of Presentation class
|
7
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'input.pptx')
|
8
|
+
|
9
|
+
# Get the first slide
|
10
|
+
slide= pres.getSlides().get_Item(0)
|
11
|
+
|
12
|
+
# Desired index
|
13
|
+
index = 0
|
14
|
+
|
15
|
+
# Accessing the added shape
|
16
|
+
ashape = slide.getShapes().get_Item(index)
|
17
|
+
|
18
|
+
# Creating output html file
|
19
|
+
os = Rjb::import('java.io.FileOutputStream').new(data_dir + "export.html")
|
20
|
+
writer = Rjb::import('java.io.OutputStreamWriter').new(os,"UTF-8")
|
21
|
+
|
22
|
+
# Extracting first paragraph as HTML
|
23
|
+
# Writing Paragraphs data to HTML by providing paragraph starting index, total paragraphs to be copied
|
24
|
+
writer.write(ashape.getTextFrame().getParagraphs().exportToHtml(0, ashape.getTextFrame().getParagraphs().getCount(), nil))
|
25
|
+
writer.close()
|
26
|
+
|
27
|
+
puts "Export text to html, please check the output file."
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Asposeslidesjava
|
2
|
+
module ImportHtml
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Text/'
|
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 the AutoShape to accomodate the HTML content
|
13
|
+
ashape = slide.getShapes().addAutoShape(Rjb::import('com.aspose.slides.ShapeType').Rectangle, 10, 10, pres.getSlideSize().getSize().getWidth(), pres.getSlideSize().getSize().getHeight())
|
14
|
+
ashape.getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').NoFill)
|
15
|
+
|
16
|
+
# Adding text frame to the shape
|
17
|
+
ashape.addTextFrame("")
|
18
|
+
|
19
|
+
# Clearing all paragraphs in added text frame
|
20
|
+
ashape.getTextFrame().getParagraphs().clear()
|
21
|
+
|
22
|
+
# Loading the HTML file using InputStream
|
23
|
+
input_stream = Rjb::import('java.io.FileInputStream').new(data_dir + "import.html")
|
24
|
+
reader = Rjb::import('java.io.InputStreamReader').new(input_stream)
|
25
|
+
|
26
|
+
data = reader.read()
|
27
|
+
content = read_file(data_dir + "import.html")
|
28
|
+
|
29
|
+
# Adding text from HTML stream reader in text frame
|
30
|
+
ashape.getTextFrame().getParagraphs().addFromHtml(content)
|
31
|
+
|
32
|
+
# Saving Presentation
|
33
|
+
pres.save(data_dir + "output.pptx", Rjb::import('com.aspose.slides.SaveFormat').Pptx)
|
34
|
+
|
35
|
+
puts "Done with html import, please check the output file."
|
36
|
+
end
|
37
|
+
|
38
|
+
def read_file(file_name)
|
39
|
+
file = Rjb::import('java.io.File').new(file_name)
|
40
|
+
contents = Rjb::import('java.lang.StringBuilder').new
|
41
|
+
reader = Rjb::import('java.io.BufferedReader').new(Rjb::import('java.io.FileReader').new(file))
|
42
|
+
|
43
|
+
# repeat until all lines is read
|
44
|
+
while (text = reader.readLine()) != nil
|
45
|
+
contents.append(text).append("\n")
|
46
|
+
end
|
47
|
+
|
48
|
+
contents.toString()
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Asposeslidesjava
|
2
|
+
module ManageFont
|
3
|
+
def initialize()
|
4
|
+
# Replacing Fonts Explicitly Inside Presentation
|
5
|
+
replace_font()
|
6
|
+
end
|
7
|
+
|
8
|
+
def replace_font()
|
9
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Text/'
|
10
|
+
|
11
|
+
# Create an instance of Presentation class
|
12
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'input.pptx')
|
13
|
+
|
14
|
+
# Load source font to be replaced
|
15
|
+
source_font = Rjb::import('com.aspose.slides.FontData').new("Arial")
|
16
|
+
|
17
|
+
# Load the replacing font
|
18
|
+
dest_font = Rjb::import('com.aspose.slides.FontData').new("Times New Roman")
|
19
|
+
|
20
|
+
# Replace the fonts
|
21
|
+
fonts_manager = Rjb::import('com.aspose.slides.FontsManager')
|
22
|
+
pres.fonts_manager.replaceFont(source_font, dest_font)
|
23
|
+
|
24
|
+
# Write the presentation as a PPTX file
|
25
|
+
pres.save(data_dir + "ReplaceFont.pptx", Rjb::import('com.aspose.slides.SaveFormat').Pptx)
|
26
|
+
|
27
|
+
puts "Replaced font, please check the output file."
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
module Asposeslidesjava
|
2
|
+
module ManageText
|
3
|
+
def initialize()
|
4
|
+
# Setting the AutofitType property of text frame
|
5
|
+
set_autofittype_of_text()
|
6
|
+
|
7
|
+
# Setting the anchor of TextFrame
|
8
|
+
set_anchor_of_text()
|
9
|
+
|
10
|
+
# Rotating the text
|
11
|
+
rotate_text()
|
12
|
+
end
|
13
|
+
|
14
|
+
def set_autofittype_of_text()
|
15
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Text/'
|
16
|
+
|
17
|
+
# Create an instance of Presentation class
|
18
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
19
|
+
|
20
|
+
# Get the first slide
|
21
|
+
slide = pres.getSlides().get_Item(0)
|
22
|
+
|
23
|
+
# Add an AutoShape of Rectangle type
|
24
|
+
ashp = slide.getShapes().addAutoShape(Rjb::import('com.aspose.slides.ShapeType').Rectangle, 150, 75, 350, 350)
|
25
|
+
|
26
|
+
# Add TextFrame to the Rectangle
|
27
|
+
ashp.addTextFrame(" ")
|
28
|
+
ashp.getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').NoFill)
|
29
|
+
|
30
|
+
# Accessing the text frame
|
31
|
+
txt_frame = ashp.getTextFrame()
|
32
|
+
|
33
|
+
# Setting text autofit type
|
34
|
+
txt_frame.getTextFrameFormat().setAutofitType(Rjb::import('com.aspose.slides.TextAutofitType').Shape)
|
35
|
+
|
36
|
+
# Create the Paragraph object for text frame
|
37
|
+
para = txt_frame.getParagraphs().get_Item(0)
|
38
|
+
|
39
|
+
# Create Portion object for paragraph
|
40
|
+
portion = para.getPortions().get_Item(0)
|
41
|
+
portion.setText("A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog.")
|
42
|
+
portion.getPortionFormat().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
|
43
|
+
portion.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').BLACK)
|
44
|
+
|
45
|
+
# Write the presentation as a PPTX file
|
46
|
+
save_format = Rjb::import('com.aspose.slides.SaveFormat')
|
47
|
+
pres.save(data_dir + "formatText.pptx", save_format.Pptx)
|
48
|
+
|
49
|
+
puts "Set autofittype of text, please check the output file."
|
50
|
+
end
|
51
|
+
|
52
|
+
def set_anchor_of_text()
|
53
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Text/'
|
54
|
+
|
55
|
+
# Create an instance of Presentation class
|
56
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
57
|
+
|
58
|
+
# Get the first slide
|
59
|
+
slide = pres.getSlides().get_Item(0)
|
60
|
+
|
61
|
+
# Add an AutoShape of Rectangle type
|
62
|
+
ashp = slide.getShapes().addAutoShape(Rjb::import('com.aspose.slides.ShapeType').Rectangle, 150, 75, 350, 350)
|
63
|
+
|
64
|
+
# Add TextFrame to the Rectangle
|
65
|
+
ashp.addTextFrame(" ")
|
66
|
+
ashp.getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').NoFill)
|
67
|
+
|
68
|
+
# Accessing the text frame
|
69
|
+
txt_frame = ashp.getTextFrame()
|
70
|
+
|
71
|
+
# Setting text anchoring to bottom
|
72
|
+
txt_frame.getTextFrameFormat().setAnchoringType(Rjb::import('com.aspose.slides.TextAnchorType').Bottom)
|
73
|
+
|
74
|
+
# Create the Paragraph object for text frame
|
75
|
+
para = txt_frame.getParagraphs().get_Item(0)
|
76
|
+
|
77
|
+
# Create Portion object for paragraph
|
78
|
+
portion = para.getPortions().get_Item(0)
|
79
|
+
portion.setText("A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog.")
|
80
|
+
portion.getPortionFormat().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
|
81
|
+
portion.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').BLACK)
|
82
|
+
|
83
|
+
# Write the presentation as a PPTX file
|
84
|
+
save_format = Rjb::import('com.aspose.slides.SaveFormat')
|
85
|
+
pres.save(data_dir + "AnchorText.pptx", save_format.Pptx)
|
86
|
+
|
87
|
+
puts "Set anchor of text, please check the output file."
|
88
|
+
end
|
89
|
+
|
90
|
+
def rotate_text()
|
91
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Text/'
|
92
|
+
|
93
|
+
# Create an instance of Presentation class
|
94
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
95
|
+
|
96
|
+
# Get the first slide
|
97
|
+
slide = pres.getSlides().get_Item(0)
|
98
|
+
|
99
|
+
# Add an AutoShape of Rectangle type
|
100
|
+
ashp = slide.getShapes().addAutoShape(Rjb::import('com.aspose.slides.ShapeType').Rectangle, 150, 75, 350, 350)
|
101
|
+
|
102
|
+
# Add TextFrame to the Rectangle
|
103
|
+
ashp.addTextFrame(" ")
|
104
|
+
ashp.getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').NoFill)
|
105
|
+
|
106
|
+
# Accessing the text frame
|
107
|
+
txt_frame = ashp.getTextFrame()
|
108
|
+
|
109
|
+
# Setting text Vertical type
|
110
|
+
txt_frame.getTextFrameFormat().setTextVerticalType(Rjb::import('com.aspose.slides.TextVerticalType').Vertical270)
|
111
|
+
|
112
|
+
# Create the Paragraph object for text frame
|
113
|
+
para = txt_frame.getParagraphs().get_Item(0)
|
114
|
+
|
115
|
+
# Create Portion object for paragraph
|
116
|
+
portion = para.getPortions().get_Item(0)
|
117
|
+
portion.setText("A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog.")
|
118
|
+
portion.getPortionFormat().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
|
119
|
+
portion.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').BLACK)
|
120
|
+
|
121
|
+
# Write the presentation as a PPTX file
|
122
|
+
save_format = Rjb::import('com.aspose.slides.SaveFormat')
|
123
|
+
pres.save(data_dir + "VerticleText.pptx", save_format.Pptx)
|
124
|
+
|
125
|
+
puts "Done with text rotation, please check the output file."
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,260 @@
|
|
1
|
+
module Asposeslidesjava
|
2
|
+
module Paragraphs
|
3
|
+
def initialize()
|
4
|
+
# Managing Paragraphs Alignment
|
5
|
+
paragraphs_alignment()
|
6
|
+
|
7
|
+
# Managing Multiple Paragraphs having Multiple Portions
|
8
|
+
multiple_paragraphs_having_muliple_portions()
|
9
|
+
|
10
|
+
# Managing Paragraph Bullets
|
11
|
+
paragraphs_bullets()
|
12
|
+
|
13
|
+
# Managing Paragraph Indent
|
14
|
+
paragraphs_indentation()
|
15
|
+
|
16
|
+
# Managing Line Spacing of the paragraph
|
17
|
+
line_spacing()
|
18
|
+
end
|
19
|
+
|
20
|
+
def paragraphs_alignment()
|
21
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Text/'
|
22
|
+
|
23
|
+
# Create an instance of Presentation class
|
24
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'leftalign.pptx')
|
25
|
+
|
26
|
+
# Get the first slide
|
27
|
+
slide = pres.getSlides().get_Item(0)
|
28
|
+
|
29
|
+
# Accessing the first and second placeholder in the slide and typecasting it as AutoShape
|
30
|
+
tf1 = slide.getShapes().get_Item(0).getTextFrame()
|
31
|
+
tf2 = slide.getShapes().get_Item(1).getTextFrame()
|
32
|
+
|
33
|
+
# Change the text in both placeholders
|
34
|
+
tf1.setText("Center Align by Aspose")
|
35
|
+
tf2.setText("Center Align by Aspose")
|
36
|
+
|
37
|
+
# Getting the first paragraph of the placeholders
|
38
|
+
para1 = tf1.getParagraphs().get_Item(0)
|
39
|
+
para2 = tf2.getParagraphs().get_Item(0)
|
40
|
+
|
41
|
+
# Aligning the text paragraph to center
|
42
|
+
para1.getParagraphFormat().setAlignment(Rjb::import('com.aspose.slides.TextAlignment').Center)
|
43
|
+
para2.getParagraphFormat().setAlignment(Rjb::import('com.aspose.slides.TextAlignment').Center)
|
44
|
+
|
45
|
+
# Write the presentation as a PPTX file
|
46
|
+
save_format = Rjb::import('com.aspose.slides.SaveFormat')
|
47
|
+
pres.save(data_dir + "Centeralign.pptx", save_format.Pptx)
|
48
|
+
|
49
|
+
puts "Done with text alignment, please check the output file."
|
50
|
+
end
|
51
|
+
|
52
|
+
def multiple_paragraphs_having_muliple_portions()
|
53
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Text/'
|
54
|
+
|
55
|
+
# Create an instance of Presentation class
|
56
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
57
|
+
|
58
|
+
# Get the first slide
|
59
|
+
slide = pres.getSlides().get_Item(0)
|
60
|
+
|
61
|
+
# Add an AutoShape of Rectangle type
|
62
|
+
ashp = slide.getShapes().addAutoShape(Rjb::import('com.aspose.slides.ShapeType').Rectangle, 50, 150, 300, 150)
|
63
|
+
|
64
|
+
# Access TextFrame of the AutoShape
|
65
|
+
tf = ashp.getTextFrame()
|
66
|
+
|
67
|
+
# Create Paragraphs and Portions with different text formats
|
68
|
+
para0 = tf.getParagraphs().get_Item(0)
|
69
|
+
port01 = Rjb::import('com.aspose.slides.Portion').new
|
70
|
+
port02 = Rjb::import('com.aspose.slides.Portion').new
|
71
|
+
para0.getPortions().add(port01)
|
72
|
+
para0.getPortions().add(port02)
|
73
|
+
|
74
|
+
para1 = Rjb::import('com.aspose.slides.Paragraph').new
|
75
|
+
tf.getParagraphs().add(para1)
|
76
|
+
port10 = Rjb::import('com.aspose.slides.Portion').new
|
77
|
+
port11 = Rjb::import('com.aspose.slides.Portion').new
|
78
|
+
port12 = Rjb::import('com.aspose.slides.Portion').new
|
79
|
+
para1.getPortions().add(port10)
|
80
|
+
para1.getPortions().add(port11)
|
81
|
+
para1.getPortions().add(port12)
|
82
|
+
|
83
|
+
para2 = Rjb::import('com.aspose.slides.Paragraph').new
|
84
|
+
tf.getParagraphs().add(para2)
|
85
|
+
port20 = Rjb::import('com.aspose.slides.Portion').new
|
86
|
+
port21 = Rjb::import('com.aspose.slides.Portion').new
|
87
|
+
port22 = Rjb::import('com.aspose.slides.Portion').new
|
88
|
+
para2.getPortions().add(port20)
|
89
|
+
para2.getPortions().add(port21)
|
90
|
+
para2.getPortions().add(port22)
|
91
|
+
|
92
|
+
i = 0
|
93
|
+
for i in 0..2
|
94
|
+
j = 0
|
95
|
+
for j in 0..2
|
96
|
+
tf.getParagraphs().get_Item(i).getPortions().get_Item(j).setText("Portion0#{j}")
|
97
|
+
if j == 0
|
98
|
+
tf.getParagraphs().get_Item(i).getPortions().get_Item(j).getPortionFormat().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
|
99
|
+
tf.getParagraphs().get_Item(i).getPortions().get_Item(j).getPortionFormat().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').RED)
|
100
|
+
tf.getParagraphs().get_Item(i).getPortions().get_Item(j).getPortionFormat().setFontBold(Rjb::import('com.aspose.slides.NullableBool').True)
|
101
|
+
tf.getParagraphs().get_Item(i).getPortions().get_Item(j).getPortionFormat().setFontHeight(15)
|
102
|
+
#elseif j == 1
|
103
|
+
# tf.getParagraphs().get_Item(i).getPortions().get_Item(j).getPortionFormat().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
|
104
|
+
# tf.getParagraphs().get_Item(i).getPortions().get_Item(j).getPortionFormat().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').BLUE)
|
105
|
+
# tf.getParagraphs().get_Item(i).getPortions().get_Item(j).getPortionFormat().setFontItalic(Rjb::import('com.aspose.slides.NullableBool').True)
|
106
|
+
# tf.getParagraphs().get_Item(i).getPortions().get_Item(j).getPortionFormat().setFontHeight(18)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# Write the presentation as a PPTX file
|
112
|
+
save_format = Rjb::import('com.aspose.slides.SaveFormat')
|
113
|
+
pres.save(data_dir + "multiParaPort.pptx", save_format.Pptx)
|
114
|
+
|
115
|
+
puts "Done with multiple paragraphs, please check the output file."
|
116
|
+
end
|
117
|
+
|
118
|
+
def paragraphs_bullets()
|
119
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Text/'
|
120
|
+
|
121
|
+
# Create an instance of Presentation class
|
122
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
123
|
+
|
124
|
+
# Get the first slide
|
125
|
+
slide = pres.getSlides().get_Item(0)
|
126
|
+
|
127
|
+
# Adding and accessing Autoshape
|
128
|
+
shp = slide.getShapes().addAutoShape(Rjb::import('com.aspose.slides.ShapeType').Rectangle, 200, 200, 400, 200)
|
129
|
+
|
130
|
+
# Accessing the text frame of created autoshape
|
131
|
+
txt_frm = shp.getTextFrame()
|
132
|
+
|
133
|
+
# Removing the default exisiting paragraph
|
134
|
+
txt_frm.getParagraphs().removeAt(0)
|
135
|
+
|
136
|
+
# Creating a paragraph
|
137
|
+
para = Rjb::import('com.aspose.slides.Paragraph').new
|
138
|
+
|
139
|
+
# Setting paragraph bullet style and symbol
|
140
|
+
para.getParagraphFormat().getBullet().setType(Rjb::import('com.aspose.slides.BulletType').Symbol)
|
141
|
+
para.getParagraphFormat().getBullet().setChar(8226)
|
142
|
+
|
143
|
+
# Setting paragraph text
|
144
|
+
para.setText("Welcome to Aspose.Slides")
|
145
|
+
|
146
|
+
# Setting bullet indent
|
147
|
+
para.getParagraphFormat().setIndent(25)
|
148
|
+
|
149
|
+
# Setting bullet color
|
150
|
+
para.getParagraphFormat().getBullet().getColor().setColorType(Rjb::import('com.aspose.slides.ColorType').RGB)
|
151
|
+
para.getParagraphFormat().getBullet().getColor().setColor(Rjb::import('java.awt.Color').BLACK)
|
152
|
+
|
153
|
+
# set IsBulletHardColor to true to use own bullet color
|
154
|
+
para.getParagraphFormat().getBullet().isBulletHardColor(Rjb::import('com.aspose.slides.NullableBool').True)
|
155
|
+
|
156
|
+
# Setting Bullet Height
|
157
|
+
para.getParagraphFormat().getBullet().setHeight(100)
|
158
|
+
|
159
|
+
# Adding Paragraph to text frame
|
160
|
+
txt_frm.getParagraphs().add(para)
|
161
|
+
|
162
|
+
# Creating second paragraph
|
163
|
+
para2 = Rjb::import('com.aspose.slides.Paragraph').new
|
164
|
+
|
165
|
+
# Setting paragraph bullet type and style
|
166
|
+
para2.getParagraphFormat().getBullet().setType(Rjb::import('com.aspose.slides.BulletType').Numbered)
|
167
|
+
para2.getParagraphFormat().getBullet().setNumberedBulletStyle(Rjb::import('com.aspose.slides.NumberedBulletStyle').BulletCircleNumWDBlackPlain)
|
168
|
+
|
169
|
+
# Adding paragraph text
|
170
|
+
para2.setText("This is numbered bullet")
|
171
|
+
|
172
|
+
# Setting bullet indent
|
173
|
+
para2.getParagraphFormat().setIndent(25)
|
174
|
+
|
175
|
+
para2.getParagraphFormat().getBullet().getColor().setColorType(Rjb::import('com.aspose.slides.ColorType').RGB)
|
176
|
+
para2.getParagraphFormat().getBullet().getColor().setColor(Rjb::import('java.awt.Color').BLACK)
|
177
|
+
|
178
|
+
# set IsBulletHardColor to true to use own bullet color
|
179
|
+
para2.getParagraphFormat().getBullet().isBulletHardColor(Rjb::import('com.aspose.slides.NullableBool').True)
|
180
|
+
|
181
|
+
# Setting Bullet Height
|
182
|
+
para2.getParagraphFormat().getBullet().setHeight(100)
|
183
|
+
|
184
|
+
# Adding Paragraph to text frame
|
185
|
+
txt_frm.getParagraphs().add(para2)
|
186
|
+
|
187
|
+
# Write the presentation as a PPTX file
|
188
|
+
save_format = Rjb::import('com.aspose.slides.SaveFormat')
|
189
|
+
pres.save(data_dir + "Bullet.pptx", save_format.Pptx)
|
190
|
+
|
191
|
+
puts "Done with Paragraphs bullet, please check the output file."
|
192
|
+
end
|
193
|
+
|
194
|
+
def paragraphs_indentation()
|
195
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Text/'
|
196
|
+
|
197
|
+
# Create an instance of Presentation class
|
198
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
199
|
+
|
200
|
+
# Get the first slide
|
201
|
+
slide = pres.getSlides().get_Item(0)
|
202
|
+
|
203
|
+
# Add a Rectangle Shape
|
204
|
+
rect = slide.getShapes().addAutoShape(Rjb::import('com.aspose.slides.ShapeType').Rectangle,100, 100, 500, 150)
|
205
|
+
|
206
|
+
# Add TextFrame to the Rectangle
|
207
|
+
tf = rect.addTextFrame("This is first line \nThis is second line \nThis is third line")
|
208
|
+
|
209
|
+
# Set the text to fit the shape
|
210
|
+
tf.getTextFrameFormat().setAutofitType(Rjb::import('com.aspose.slides.TextAutofitType').Shape)
|
211
|
+
|
212
|
+
# Hide the lines of the Rectangle
|
213
|
+
rect.getLineFormat().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
|
214
|
+
|
215
|
+
# Get first Paragraph in the TextFrame and set its Indent
|
216
|
+
para1 = tf.getParagraphs().get_Item(0)
|
217
|
+
|
218
|
+
# Setting paragraph bullet style and symbol
|
219
|
+
para1.getParagraphFormat().getBullet().setType(Rjb::import('com.aspose.slides.BulletType').Symbol)
|
220
|
+
para1.getParagraphFormat().getBullet().setChar(8226)
|
221
|
+
para1.getParagraphFormat().setAlignment(Rjb::import('com.aspose.slides.TextAlignment').Left)
|
222
|
+
|
223
|
+
para1.getParagraphFormat().setDepth(2)
|
224
|
+
para1.getParagraphFormat().setIndent(30)
|
225
|
+
|
226
|
+
# Write the presentation as a PPTX file
|
227
|
+
save_format = Rjb::import('com.aspose.slides.SaveFormat')
|
228
|
+
pres.save(data_dir + "InOutDent.pptx", save_format.Pptx)
|
229
|
+
|
230
|
+
puts "Done with paragraphs identation, please check the output file."
|
231
|
+
end
|
232
|
+
|
233
|
+
def line_spacing()
|
234
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Text/'
|
235
|
+
|
236
|
+
# Create an instance of Presentation class
|
237
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'Welcome.pptx')
|
238
|
+
|
239
|
+
# Get the first slide
|
240
|
+
slide = pres.getSlides().get_Item(0)
|
241
|
+
|
242
|
+
# Access the TextFrame
|
243
|
+
tf = slide.getShapes().get_Item(0).getTextFrame()
|
244
|
+
|
245
|
+
# Access the Paragraph
|
246
|
+
para = tf.getParagraphs().get_Item(0)
|
247
|
+
|
248
|
+
# Set properties of Paragraph
|
249
|
+
para.getParagraphFormat().setSpaceWithin(80)
|
250
|
+
para.getParagraphFormat().setSpaceBefore(40)
|
251
|
+
para.getParagraphFormat().setSpaceAfter(40)
|
252
|
+
|
253
|
+
# Write the presentation as a PPTX file
|
254
|
+
save_format = Rjb::import('com.aspose.slides.SaveFormat')
|
255
|
+
pres.save(data_dir + "LineSpacing.pptx", save_format.Pptx)
|
256
|
+
|
257
|
+
puts "Done with line spacing, please check the output file."
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|