Skip to content

Commit 3ea62e5

Browse files
Merge pull request #13 from fahadadeel/master
Aspose.Slides Java for Jython Examples
2 parents 530fd36 + 8d1fad7 commit 3ea62e5

File tree

101 files changed

+3603
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+3603
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Aspose.Slides Java for Jython
2+
3+
Aspose.Slides Java for Jython is a project that demonstrates / provides the Aspose.Slides for Java API usage examples in Jython.
4+
5+
## Download
6+
7+
* To download Aspose.Slides for Java API to be used with these examples, Please navigate to [Aspose.Slides for Java](http://www.aspose.com/community/files/72/java-components/aspose.slides-for-java/)
8+
* Place downloaded jar file into "lib" directory.
9+
* Replace "your-lib" with the jar filename.
10+
11+
## Documentation
12+
13+
For most complete documentation of the project, check [Aspose.Slides Java For Jython confluence wiki](http://www.aspose.com/docs/display/slidesjava/Aspose.Slides+Java+for+Jython).
14+
15+
## Download Latest Versions?
16+
17+
* [Latest Releases on Codeplex](http://asposeslidesjavajython.codeplex.com/releasesce)
18+
19+
## Clone Plugin SourceCodes?
20+
21+
This project is also hosted and maintained at CodePlex. To clone navigate to:
22+
23+
* [Aspose.Slides Java for Jython on CodePlex - click here](https://asposeslidesjavajython.codeplex.com/SourceControl/latest)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Metadata-Version: 1.1
2+
Name: aspose-slides-java-for-jython
3+
Version: 1.0.0
4+
Summary: Aspose.slides Java for Jython is a project that demonstrates / provides the Aspose.Slides for Java API usage examples in Jython.
5+
Home-page: https://github.com/asposeslides/Aspose_Slides_Java/tree/master/Plugins/Aspose-Slides-Java-for-Jython
6+
Author: Fahad Adeel
7+
Author-email: [email protected]
8+
License: UNKNOWN
9+
Description: UNKNOWN
10+
Platform: UNKNOWN
11+
Classifier: Programming Language :: Python
12+
Classifier: Programming Language :: Python :: 2
13+
Classifier: License :: OSI Approved :: MIT License
14+
Classifier: Operating System :: OS Independent
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
setup.py
2+
aspose_slides_java_for_jython.egg-info/PKG-INFO
3+
aspose_slides_java_for_jython.egg-info/SOURCES.txt
4+
aspose_slides_java_for_jython.egg-info/dependency_links.txt
5+
aspose_slides_java_for_jython.egg-info/top_level.txt
6+
asposeslides/__init__.py
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
asposeslides
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from asposeslides import Settings
2+
from com.aspose.slides import Presentation
3+
from com.aspose.slides import ShapeType
4+
from com.aspose.slides import FillType
5+
from com.aspose.slides import SaveFormat
6+
from java.awt import Color
7+
8+
class HelloWorld:
9+
10+
def __init__(self):
11+
12+
dataDir = Settings.dataDir + 'IntroductionToPresentation/HelloWorld'
13+
14+
# Instantiate Presentation
15+
pres = Presentation()
16+
17+
# Get the first slide
18+
slide = pres.getSlides().get_Item(0)
19+
20+
# Add an AutoShape of Rectangle type
21+
shape_type = ShapeType
22+
ashp = slide.getShapes().addAutoShape(shape_type.Rectangle, 150, 75, 150, 50)
23+
24+
# Add ITextFrame to the Rectangle
25+
ashp.addTextFrame("Hello World")
26+
27+
# Change the text color to Black (which is White by default)
28+
fill_type = FillType
29+
color = Color
30+
ashp.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().getFillFormat().setFillType(fill_type.Solid)
31+
ashp.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().getFillFormat().getSolidFillColor().setColor(color.BLACK)
32+
33+
# Change the line color of the rectangle to White
34+
ashp.getShapeStyle().getLineColor().setColor(color.WHITE)
35+
36+
# Remove any fill formatting in the shape
37+
ashp.getFillFormat().setFillType (fill_type.NoFill)
38+
39+
# Save the presentation to disk
40+
save_format = SaveFormat
41+
pres.save(dataDir + "HelloWorld.pptx", save_format.Pptx)
42+
43+
print "Document has been saved, please check the output file."
44+
45+
if __name__ == '__main__':
46+
HelloWorld()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from asposeslides import Settings
2+
from com.aspose.slides import Presentation
3+
from com.aspose.slides import ControlType
4+
from com.aspose.slides import SaveFormat
5+
6+
class AddActiveX:
7+
8+
def __init__(self):
9+
10+
dataDir = Settings.dataDir + 'WorkingWithActiveXControls/'
11+
# Create an instance of Presentation class
12+
pres = Presentation()
13+
14+
# Adding the Media Player ActiveX control
15+
controlType = ControlType
16+
pres.getSlides().get_Item(0).getControls().addControl(controlType.WindowsMediaPlayer, 100, 100, 400, 400)
17+
18+
# Access the Media Player ActiveX control and set the video path
19+
pres.getSlides().get_Item(0).getControls().get_Item(0).getProperties().set_Item("URL" , dataDir + "Wildlife.mp4")
20+
21+
# Write the presentation as a PPTX file
22+
saveFormat = SaveFormat
23+
pres.save(dataDir + "AddActiveX.pptx", saveFormat.Pptx)
24+
25+
print "Added ActiveX control, please check the output file."
26+
27+
if __name__ == '__main__':
28+
AddActiveX()
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from asposeslides import Settings
2+
from com.aspose.slides import Presentation
3+
from com.aspose.slides import ShapeType
4+
from com.aspose.slides import FillType
5+
from com.aspose.slides import SaveFormat
6+
from java.awt import Color
7+
8+
class ChartLegend:
9+
10+
def __init__(self):
11+
12+
dataDir = Settings.dataDir + 'WorkingWithCharts/'
13+
14+
# Instantiate Presentation
15+
pres = Presentation()
16+
17+
# Get the first slide
18+
slide = pres.getSlides().get_Item(0)
19+
20+
# Add an AutoShape of Rectangle type
21+
shape_type = ShapeType
22+
ashp = slide.getShapes().addAutoShape(shape_type.Rectangle, 150, 75, 150, 50)
23+
24+
# Add ITextFrame to the Rectangle
25+
ashp.addTextFrame("Hello World")
26+
27+
# Change the text color to Black (which is White by default)
28+
fill_type = FillType
29+
color = Color
30+
ashp.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().getFillFormat().setFillType(fill_type.Solid)
31+
ashp.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().getFillFormat().getSolidFillColor().setColor(color.BLACK)
32+
33+
# Change the line color of the rectangle to White
34+
ashp.getShapeStyle().getLineColor().setColor(color.WHITE)
35+
36+
# Remove any fill formatting in the shape
37+
ashp.getFillFormat().setFillType (fill_type.NoFill)
38+
39+
# Save the presentation to disk
40+
save_format = SaveFormat
41+
pres.save(dataDir + "HelloWorld.pptx", save_format.Pptx)
42+
43+
print "Document has been saved, please check the output file."
44+
45+
if __name__ == '__main__':
46+
ChartLegend()
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
from asposeslides import Settings
2+
from com.aspose.slides import Presentation
3+
from com.aspose.slides import ChartType
4+
from com.aspose.slides import SaveFormat
5+
6+
class ChartProperties:
7+
8+
def __init__(self):
9+
10+
# Setting the RotationX, RotationY and DepthPercents properties of 3D Chart.
11+
self.set_rotation_and_depth()
12+
13+
# Setting the GapWidth property of Chart Series
14+
self.set_gapwidth()
15+
16+
def set_rotation_and_depth(dataDir):
17+
18+
dataDir = Settings.dataDir + 'WorkingWithCharts/ChartProperties'
19+
20+
pres = Presentation()
21+
22+
# Access first slide
23+
sld = pres.getSlides().get_Item(0)
24+
25+
# Add chart with default data
26+
charType=ChartType
27+
chart = sld.getShapes().addChart(charType.StackedColumn3D, 0, 0, 500, 500)
28+
29+
# Getting the chart data worksheet
30+
fact = chart.getChartData().getChartDataWorkbook()
31+
32+
# Delete default generated series and categories
33+
chart.getChartData().getSeries().clear()
34+
chart.getChartData().getCategories().clear()
35+
36+
# Adding series
37+
chart.getChartData().getSeries().add(fact.getCell(0, 0, 1, "Series 1"), chart.getType())
38+
chart.getChartData().getSeries().add(fact.getCell(0, 0, 2, "Series 2"), chart.getType())
39+
40+
# Adding categories
41+
chart.getChartData().getCategories().add(fact.getCell(0, 1, 0, "Caetegoty 1"))
42+
chart.getChartData().getCategories().add(fact.getCell(0, 2, 0, "Caetegoty 2"))
43+
chart.getChartData().getCategories().add(fact.getCell(0, 3, 0, "Caetegoty 3"))
44+
45+
# Set Rotation3D properties
46+
chart.getRotation3D().setRightAngleAxes(True)
47+
chart.getRotation3D().setRotationX(40)
48+
chart.getRotation3D().setRotationY(270)
49+
chart.getRotation3D().setDepthPercents(150)
50+
51+
# Take first chart series
52+
series = chart.getChartData().getSeries().get_Item(0)
53+
54+
# Populating series data
55+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 1, 20))
56+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 1, 50))
57+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 1, 30))
58+
59+
# Take second chart series
60+
series = chart.getChartData().getSeries().get_Item(1)
61+
62+
# Populating series data
63+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 2, 30))
64+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 2, 10))
65+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 2, 60))
66+
67+
# Saving the presentation
68+
save_format = SaveFormat
69+
pres.save(dataDir + "3Drotation.pptx", save_format.Pptx)
70+
71+
print "Done with rotation, please check the output file."
72+
73+
def set_gapwidth(dataDir):
74+
75+
dataDir = Settings.dataDir + 'WorkingWithCharts/ChartProperties'
76+
77+
pres = Presentation()
78+
79+
# Access first slide
80+
sld = pres.getSlides().get_Item(0)
81+
82+
# Add chart with default data
83+
charType=ChartType
84+
chart = sld.getShapes().addChart(charType.StackedColumn3D, 0, 0, 500, 500)
85+
86+
# Getting the chart data worksheet
87+
fact = chart.getChartData().getChartDataWorkbook()
88+
89+
# Delete default generated series and categories
90+
chart.getChartData().getSeries().clear()
91+
chart.getChartData().getCategories().clear()
92+
93+
# Adding series
94+
chart.getChartData().getSeries().add(fact.getCell(0, 0, 1, "Series 1"), chart.getType())
95+
chart.getChartData().getSeries().add(fact.getCell(0, 0, 2, "Series 2"), chart.getType())
96+
97+
# Adding categories
98+
chart.getChartData().getCategories().add(fact.getCell(0, 1, 0, "Caetegoty 1"))
99+
chart.getChartData().getCategories().add(fact.getCell(0, 2, 0, "Caetegoty 2"))
100+
chart.getChartData().getCategories().add(fact.getCell(0, 3, 0, "Caetegoty 3"))
101+
102+
# Take first chart series
103+
series = chart.getChartData().getSeries().get_Item(0)
104+
105+
# Populating series data
106+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 1, 20))
107+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 1, 50))
108+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 1, 30))
109+
110+
# Take second chart series
111+
series = chart.getChartData().getSeries().get_Item(1)
112+
113+
# Populating series data
114+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 2, 30))
115+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 2, 10))
116+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 2, 60))
117+
118+
# Set GapWidth value
119+
series.getParentSeriesGroup().setGapWidth(75)
120+
121+
# Saving the presentation
122+
save_format = SaveFormat
123+
pres.save(dataDir + "SetGapWidth.pptx", save_format.Pptx)
124+
125+
print "Set Gapwidth property of chart series, please check the output file."
126+
127+
if __name__ == '__main__':
128+
ChartProperties()
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from asposeslides import Settings
2+
from com.aspose.slides import Presentation
3+
from com.aspose.slides import ChartType
4+
from com.aspose.slides import SaveFormat
5+
6+
class ChartSeries:
7+
8+
def __init__(self):
9+
10+
# Adding Chart Series Overlap for Charts
11+
self.add_overlap_for_chart()
12+
13+
def add_overlap_for_chart(dataDir):
14+
15+
dataDir = Settings.dataDir + 'WorkingWithCharts/ChartSeries'
16+
17+
# Instantiate Presentation class that represents the presentation file
18+
pres = Presentation()
19+
20+
# Adding chart
21+
chartType = ChartType
22+
23+
chart = pres.getSlides().get_Item(0).getShapes().addChart(chartType.ClusteredColumn, 50, 50, 600, 400, True)
24+
25+
series = chart.getChartData().getSeries()
26+
if (series.get_Item(0).getOverlap() == 0):
27+
# Setting series overlap
28+
series . get_Item(0) . getParentSeriesGroup().setOverlap(-30)
29+
30+
# Saving the presentation
31+
save_format = SaveFormat
32+
pres.save(dataDir + "Overlap.pptx", save_format.Pptx)
33+
34+
print "Added chart series overlap for charts, please check the output file."
35+
36+
if __name__ == '__main__':
37+
ChartSeries()

0 commit comments

Comments
 (0)