Skip to content

Commit 80de209

Browse files
Merge pull request #9 from fahadadeel/master
Aspose_Slides_Java_for_PHP Examples
2 parents a0d65de + 17d770f commit 80de209

File tree

136 files changed

+4575
-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.

136 files changed

+4575
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Aspose.Slides Java for PHP
2+
Aspose Slides Java for PHP is a PHP project that demonstrates / provides the Aspose.Slides for Java API usage examples in PHP by using PHP/JAVA Bridge.
3+
4+
You will need to configure PHP/Java Bridge before using any of the Aspose provided Java APIs in PHP e.g Aspose.Words, Aspose.Cells and Aspose.Slides etc.
5+
6+
For the configuration/setup of PHP/Java Bridge, please see:
7+
8+
http://php-java-bridge.sourceforge.net/pjb/index.php
9+
10+
To download Aspose.Cells for Java API to be used with these examples through PHP/Java Bridge
11+
Please navigate to:
12+
13+
http://www.aspose.com/community/files/72/java-components/aspose.slides-for-java/
14+
15+
For most complete documentation of the project, check Aspose.Slides Java for PHP confluence wiki link:
16+
17+
http://www.aspose.com/docs/display/slidesjava/5.+Aspose.Slides+Java+for+PHP
18+
19+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "asposeslides/aspose_slides_java_for_php",
3+
"description": "Aspose Slides Java Examples for PHP Developers. Helps you understand how to use Aspose.Slides Java classes in your PHP Projects.",
4+
"type": "library",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Fahad Adeel",
9+
"email": "[email protected]"
10+
}
11+
],
12+
"minimum-stability": "dev",
13+
"require": {
14+
"php": ">=5.3.0"
15+
},
16+
"autoload": {
17+
"psr-4": {
18+
"Aspose\\Slides\\": "src/aspose/slides"
19+
}
20+
}
21+
}

Plugins/Aspose_Slides_Java_for_PHP/composer.lock

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace Aspose\Slides\IntroductionToPresentation;
4+
5+
use com\aspose\slides\Presentation as Presentation;
6+
use com\aspose\slides\ShapeType as ShapeType;
7+
use com\aspose\slides\FillType as FillType;
8+
use com\aspose\slides\SaveFormat as SaveFormat;
9+
use java\awt\Color as Color;
10+
11+
class HelloWorld {
12+
13+
public static function run($dataDir=null)
14+
{
15+
16+
# Instantiate Presentation
17+
$pres = new Presentation();
18+
19+
# Get the first slide
20+
$slide = $pres->getSlides()->get_Item(0);
21+
22+
# Add an AutoShape of Rectangle type
23+
$shape_type = new ShapeType();
24+
$ashp = $slide->getShapes()->addAutoShape($shape_type->Rectangle, 150, 75, 150, 50);
25+
26+
# Add ITextFrame to the Rectangle
27+
$ashp->addTextFrame("Hello World");
28+
29+
# Change the text color to Black (which is White by default)
30+
$fill_type = new FillType();
31+
$color = new Color();
32+
$ashp->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0)->getPortionFormat()->getFillFormat()->setFillType($fill_type->Solid);
33+
$ashp->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0)->getPortionFormat()->getFillFormat()->getSolidFillColor()->setColor($color->BLACK);
34+
35+
# Change the line color of the rectangle to White
36+
$ashp->getShapeStyle()->getLineColor()->setColor($color->WHITE);
37+
38+
# Remove any fill formatting in the shape
39+
$ashp->getFillFormat()->setFillType ($fill_type->NoFill);
40+
41+
# Save the presentation to disk
42+
$save_format = new SaveFormat();
43+
$pres->save($dataDir . "HelloWorld.pptx", $save_format->Pptx);
44+
45+
print "Document has been saved, please check the output file.";
46+
47+
}
48+
49+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
namespace Aspose\Slides\WorkingWithActiveXControls;
3+
4+
use com\aspose\slides\Presentation as Presentation;
5+
use com\aspose\slides\ControlType as ControlType;
6+
use com\aspose\slides\SaveFormat as SaveFormat;
7+
8+
class AddActiveX{
9+
10+
public static function run($dataDir=null){
11+
12+
# Create an instance of Presentation class
13+
$pres = new Presentation();
14+
15+
# Adding the Media Player ActiveX control
16+
$controlType = new ControlType();
17+
$pres->getSlides()->get_Item(0)->getControls()->addControl($controlType->WindowsMediaPlayer, 100, 100, 400, 400);
18+
19+
# Access the Media Player ActiveX control and set the video path
20+
$pres->getSlides()->get_Item(0)->getControls()->get_Item(0)->getProperties()->set_Item("URL" , $dataDir . "Wildlife.mp4");
21+
22+
# Write the presentation as a PPTX file
23+
$saveFormat = new SaveFormat();
24+
$pres->save($dataDir . "AddActiveX.pptx", $saveFormat->Pptx);
25+
26+
print "Added ActiveX control, please check the output file.".PHP_EOL;
27+
}
28+
29+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
namespace Aspose\Slides\WorkingWithCharts;
4+
5+
use com\aspose\slides\Presentation as Presentation;
6+
use com\aspose\slides\SaveFormat as SaveFormat;
7+
use com\aspose\slides\ShapeType as ShapeType;
8+
use com\aspose\slides\ChartType as ChartType;
9+
use com\aspose\slides\LineDashStyle as LineDashStyle;
10+
use com\aspose\slides\LineArrowheadLength as LineArrowheadLength;
11+
use com\aspose\slides\LineArrowheadStyle as LineArrowheadStyle;
12+
use com\aspose\slides\PresetColor as PresetColor;
13+
use com\aspose\slides\FillType as FillType;
14+
use com\aspose\slides\NullableBool as NullableBool;
15+
use com\aspose\slides\MarkerStyleType as MarkerStyleType;
16+
use java\awt\Color as Color;
17+
18+
19+
class ChartLegend
20+
{
21+
22+
public static function run($dataDir = null)
23+
{
24+
# Setting Custom Location and Size for Chart legend
25+
ChartLegend::set_location_and_size($dataDir);
26+
27+
}
28+
29+
public static function set_location_and_size($dataDir=null){
30+
31+
# Creating empty presentation
32+
$pres = new Presentation();
33+
34+
# Get reference of the slide
35+
$slide = $pres->getSlides()->get_Item(0);
36+
37+
# Add a clustered column chart on the slide
38+
39+
$chartType=new ChartType();
40+
41+
$chart = $slide->getShapes()->addChart($chartType->ClusteredColumn, 50, 50, 500, 500);
42+
43+
# Set Legend Properties
44+
$chart->getLegend()->setX(50 / $chart->getWidth());
45+
$chart->getLegend()->setY (50 / $chart->getHeight());
46+
$chart->getLegend()->setWidth(100 / $chart->getWidth());
47+
$chart->getLegend()->setHeight(100 / $chart->getHeight());
48+
49+
# Saving the presentation
50+
$save_format = new SaveFormat();
51+
$pres->save($dataDir . "Legend.pptx", $save_format->Pptx);
52+
53+
print "Set custom location and size of chart legend, please check the output file.".PHP_EOL;
54+
}
55+
}
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<?php
2+
namespace Aspose\Slides\WorkingWithCharts;
3+
4+
use com\aspose\slides\Presentation as Presentation;
5+
use com\aspose\slides\ChartType as ChartType;
6+
use com\aspose\slides\SaveFormat as SaveFormat;
7+
8+
class ChartProperties{
9+
10+
public static function run($dataDir=null){
11+
# Setting the RotationX, RotationY and DepthPercents properties of 3D Chart.
12+
ChartProperties::set_rotation_and_depth($dataDir);
13+
14+
# Setting the GapWidth property of Chart Series
15+
ChartProperties::set_gapwidth($dataDir);
16+
}
17+
18+
public static function set_rotation_and_depth($dataDir=null){
19+
20+
$pres = new Presentation();
21+
22+
# Access first slide
23+
$sld = $pres->getSlides()->get_Item(0);
24+
25+
# Add chart with default data
26+
$charType=new 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 new 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 new 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 = new SaveFormat();
69+
$pres->save($dataDir . "3Drotation.pptx", $save_format->Pptx);
70+
71+
print "Done with rotation, please check the output file.".PHP_EOL;
72+
}
73+
74+
public static function set_gapwidth($dataDir=null){
75+
76+
$pres = new Presentation();
77+
78+
# Access first slide
79+
$sld = $pres->getSlides()->get_Item(0);
80+
81+
# Add chart with default data
82+
$charType=new ChartType();
83+
$chart = $sld->getShapes()->addChart($charType->StackedColumn3D, 0, 0, 500, 500);
84+
85+
# Getting the chart data worksheet
86+
$fact = $chart->getChartData()->getChartDataWorkbook();
87+
88+
# Delete default generated series and categories
89+
$chart->getChartData()->getSeries()->clear();
90+
$chart->getChartData()->getCategories()->clear();
91+
92+
# Adding new series
93+
$chart->getChartData()->getSeries()->add($fact->getCell(0, 0, 1, "Series 1"), $chart->getType());
94+
$chart->getChartData()->getSeries()->add($fact->getCell(0, 0, 2, "Series 2"), $chart->getType());
95+
96+
# Adding new categories
97+
$chart->getChartData()->getCategories()->add($fact->getCell(0, 1, 0, "Caetegoty 1"));
98+
$chart->getChartData()->getCategories()->add($fact->getCell(0, 2, 0, "Caetegoty 2"));
99+
$chart->getChartData()->getCategories()->add($fact->getCell(0, 3, 0, "Caetegoty 3"));
100+
101+
# Take first chart series
102+
$series = $chart->getChartData()->getSeries()->get_Item(0);
103+
104+
# Populating series data
105+
$series->getDataPoints()->addDataPointForBarSeries($fact->getCell(0, 1, 1, 20));
106+
$series->getDataPoints()->addDataPointForBarSeries($fact->getCell(0, 2, 1, 50));
107+
$series->getDataPoints()->addDataPointForBarSeries($fact->getCell(0, 3, 1, 30));
108+
109+
# Take second chart series
110+
$series = $chart->getChartData()->getSeries()->get_Item(1);
111+
112+
# Populating series data
113+
$series->getDataPoints()->addDataPointForBarSeries($fact->getCell(0, 1, 2, 30));
114+
$series->getDataPoints()->addDataPointForBarSeries($fact->getCell(0, 2, 2, 10));
115+
$series->getDataPoints()->addDataPointForBarSeries($fact->getCell(0, 3, 2, 60));
116+
117+
# Set GapWidth value
118+
$series->getParentSeriesGroup()->setGapWidth(75);
119+
120+
# Saving the presentation
121+
$save_format = new SaveFormat();
122+
$pres->save($dataDir . "SetGapWidth.pptx", $save_format->Pptx);
123+
124+
print "Set Gapwidth property of chart series, please check the output file.".PHP_EOL;
125+
126+
}
127+
128+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
namespace Aspose\Slides\WorkingWithCharts;
3+
4+
use com\aspose\slides\Presentation as Presentation;
5+
use com\aspose\slides\ChartType as ChartType;
6+
use com\aspose\slides\SaveFormat as SaveFormat;
7+
8+
class ChartSeries{
9+
10+
public static function run($dataDir = null){
11+
# Adding Chart Series Overlap for Charts
12+
ChartSeries::add_overlap_for_chart($dataDir);
13+
}
14+
15+
public static function add_overlap_for_chart($dataDir=null)
16+
{
17+
# Instantiate Presentation class that represents the presentation file
18+
$pres = new Presentation();
19+
20+
# Adding chart
21+
$chartType = new 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+
31+
# Saving the presentation
32+
$save_format = new SaveFormat();
33+
$pres->save($dataDir . "Overlap.pptx", $save_format->Pptx);
34+
35+
print "Added chart series overlap for charts, please check the output file.".PHP_EOL;
36+
}
37+
38+
}

0 commit comments

Comments
 (0)