Ejemplo n.º 1
0
 public static function add_arrow_line($dataDir = null)
 {
     # Create an instance of Presentation class
     $pres = new Presentation();
     # Get the first slide
     $sld = $pres->getSlides()->get_Item(0);
     # Add an autoshape of type line
     $shapeType = new ShapeType();
     $shp = $sld->getShapes()->addAutoShape($shapeType->Line, 50, 150, 300, 0);
     # Apply some formatting on the line
     $lineStyle = new LineStyle();
     $shp->getLineFormat()->setStyle($lineStyle->ThickBetweenThin);
     $shp->getLineFormat()->setWidth(10);
     $lineDashStyle = new LineDashStyle();
     $shp->getLineFormat()->setDashStyle($lineDashStyle->DashDot);
     $lineArrowheadLength = new LineArrowheadLength();
     $lineArrowheadStyle = new LineArrowheadStyle();
     $fillType = new FillType();
     $color = new Color();
     $presetColor = new PresetColor();
     $shp->getLineFormat()->setBeginArrowheadLength($lineArrowheadLength->Short);
     $shp->getLineFormat()->setBeginArrowheadStyle($lineArrowheadStyle->Oval);
     $shp->getLineFormat()->setEndArrowheadLength($lineArrowheadLength->Long);
     $shp->getLineFormat()->setEndArrowheadStyle($lineArrowheadStyle->Triangle);
     $shp->getLineFormat()->getFillFormat()->setFillType($fillType->Solid);
     $shp->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor(new Color($presetColor->Maroon));
     # Write the presentation as a PPTX file
     $save_format = new SaveFormat();
     $pres->save($dataDir . "ArrowShape.pptx", $save_format->Pptx);
     print "Added arrow shape line to slide, please check the output file." . PHP_EOL;
 }
 public static function convert_with_custom_size($dataDir = null)
 {
     # Instantiate a Presentation object that represents a PPTX file
     $pres = new Presentation($dataDir . "Aspose.pptx");
     # Instantiate the TiffOptions class
     $opts = new TiffOptions();
     # Setting compression type
     $tiff_compression_types = new TiffCompressionTypes();
     $opts->setCompressionType($tiff_compression_types->Default);
     # Compression Types
     #Default - Specifies the default compression scheme (LZW).
     #None - Specifies no compression.
     #CCITT3
     #CCITT4
     #LZW
     #RLE
     # Depth – depends on the compression type and cannot be set manually.
     # Resolution unit – is always equal to “2” (dots per inch)
     #Setting image DPI
     $opts->setDpiX(200);
     $opts->setDpiY(100);
     # Set Image Size
     $opts->setImageSize(new Dimension(1728, 1078));
     # Save the presentation to TIFF with specified image size
     $save_format = new SaveFormat();
     $pres->save($dataDir . "Aspose-Custom-Size.tiff", $save_format->Tiff, $opts);
     print "Document has been converted, please check the output file.";
 }
Ejemplo n.º 3
0
 public static function run($dataDir = null)
 {
     # Instantiate Presentation
     $pres = new Presentation();
     # Get the first slide
     $slide = $pres->getSlides()->get_Item(0);
     # Add an AutoShape of Rectangle type
     $shape_type = new ShapeType();
     $ashp = $slide->getShapes()->addAutoShape($shape_type->Rectangle, 150, 75, 150, 50);
     # Add ITextFrame to the Rectangle
     $ashp->addTextFrame("Hello World");
     # Change the text color to Black (which is White by default)
     $fill_type = new FillType();
     $color = new Color();
     $ashp->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0)->getPortionFormat()->getFillFormat()->setFillType($fill_type->Solid);
     $ashp->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0)->getPortionFormat()->getFillFormat()->getSolidFillColor()->setColor($color->BLACK);
     # Change the line color of the rectangle to White
     $ashp->getShapeStyle()->getLineColor()->setColor($color->WHITE);
     # Remove any fill formatting in the shape
     $ashp->getFillFormat()->setFillType($fill_type->NoFill);
     # Save the presentation to disk
     $save_format = new SaveFormat();
     $pres->save($dataDir . "HelloWorld.pptx", $save_format->Pptx);
     print "Document has been saved, please check the output file.";
 }
Ejemplo n.º 4
0
 public static function run($dataDir = null)
 {
     # Create an instance of Presentation class
     $pres = new Presentation();
     # Get the first slide
     $slide = $pres->getSlides()->get_Item(0);
     # Add an AutoShape of Rectangle type
     $shapeType = new ShapeType();
     $shp = $slide->getShapes()->addAutoShape($shapeType->Rectangle, 150, 75, 150, 50);
     # Add TextFrame to the Rectangle
     $shp->addTextFrame("Aspose TextBox");
     # Disable shape fill in case we want to get shadow of text
     $fillType = new FillType();
     $shp->getFillFormat()->setFillType($fillType->NoFill);
     # Add outer shadow and set all necessary parameters
     $shp->getEffectFormat()->enableOuterShadowEffect();
     $shadow = $shp->getEffectFormat()->getOuterShadowEffect();
     $shadow->setBlurRadius(4.0);
     $shadow->setDirection(45);
     $shadow->setDistance(3);
     $rectangleAlignment = new RectangleAlignment();
     $color = new Color();
     $shadow->setRectangleAlign($rectangleAlignment->TopLeft);
     $shadow->getShadowColor()->setColor($color->black);
     # Write the presentation as a PPTX file
     $save_format = new SaveFormat();
     $pres->save($dataDir . "OutShadow.pptx", $save_format->Pptx);
     print "Applied shadow effects on text, please check the output file." . PHP_EOL;
 }
Ejemplo n.º 5
0
 public static function run($dataDir = null)
 {
     # Create an instance of Presentation class
     $pres = new Presentation();
     # Get the first slide
     $slide = $pres->getSlides()->get_Item(0);
     # Add an AutoShape of Rectangle type
     $shapeType = new ShapeType();
     $fillType = new FillType();
     $ashp = $slide->getShapes()->addAutoShape($shapeType->Rectangle, 150, 75, 400, 300);
     $ashp->getFillFormat()->setFillType($fillType->NoFill);
     # Add TextFrame to the Rectangle
     $ashp->addTextFrame("Aspose TextBox");
     $port = $ashp->getTextFrame()->getParagraphs()->get_Item(0)->getPortions()->get_Item(0);
     $pf = $port->getPortionFormat();
     $pf->setFontHeight(50);
     # Enable InnerShadowEffect
     $ef = $pf->getEffectFormat();
     $ef->enableInnerShadowEffect();
     # Set all necessary parameters
     $ef->getInnerShadowEffect()->setBlurRadius(8.0);
     $ef->getInnerShadowEffect()->setDirection(90);
     $ef->getInnerShadowEffect()->setDistance(6.0);
     $ef->getInnerShadowEffect()->getShadowColor()->setB(189);
     # Set ColorType as Scheme
     $colorType = new ColorType();
     $ef->getInnerShadowEffect()->getShadowColor()->setColorType($colorType->Scheme);
     # Set Scheme Color
     $schemeColor = new SchemeColor();
     $ef->getInnerShadowEffect()->getShadowColor()->setSchemeColor($schemeColor->Accent1);
     # Write the presentation as a PPTX file
     $save_format = new SaveFormat();
     $pres->save($dataDir . "WordArt.pptx", $save_format->Pptx);
     print "Done with word art, please check the output file." . PHP_EOL;
 }
 public static function convert_to_pdf_notes($dataDir = null)
 {
     # Instantiate a Presentation object that represents a PPTX file
     $pres = new Presentation($dataDir . "Aspose.pptx");
     # Saving the presentation
     $save_format = new SaveFormat();
     $pres->save($dataDir . "Notes.pdf", $save_format->pdf);
     print "Document has been converted, please check the output file.";
 }
Ejemplo n.º 7
0
 public static function run($dataDir = null)
 {
     # Instantiate a Presentation object that represents a PPTX file
     $pres = new Presentation($dataDir . "Presentation1.ppt");
     # Saving the PPTX presentation to PPTX format
     $save_format = new SaveFormat();
     $pres->save($dataDir . "Aspose.pptx", $save_format->Pptx);
     print "Document has been converted, please check the output file.";
 }
Ejemplo n.º 8
0
 public static function run($dataDir = null)
 {
     $pres = new Presentation();
     # Get the first slide
     $sld = $pres->getSlides()->get_Item(0);
     # Define columns with widths and rows with heights
     $dbl_cols = [50, 50, 50];
     $dbl_rows = [50, 30, 30, 30];
     # Add table shape to slide
     $tbl = $sld->getShapes()->addTable(100, 50, $dbl_cols, $dbl_rows);
     $fill_type = new FillType();
     $color = new Color();
     # Set border format for each cell
     $row = 0;
     while ($row < java_values($tbl->getRows()->size())) {
         $cell = 0;
         while ($cell < $tbl->getRows()->get_Item($row)->size()) {
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderTop()->getFillFormat()->setFillType($fill_type->Solid);
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderTop()->getFillFormat()->getSolidFillColor()->setColor($color->RED);
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderTop()->setWidth(5);
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderBottom()->getFillFormat()->setFillType($fill_type->Solid);
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderBottom()->getFillFormat()->getSolidFillColor()->setColor($color->RED);
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderBottom()->setWidth(5);
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderLeft()->getFillFormat()->setFillType($fill_type->Solid);
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderLeft()->getFillFormat()->getSolidFillColor()->setColor($color->RED);
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderLeft()->setWidth(5);
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderRight()->getFillFormat()->setFillType($fill_type->Solid);
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderRight()->getFillFormat()->getSolidFillColor()->setColor($color->RED);
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderRight()->setWidth(5);
             $cell += 1;
         }
         $row += 1;
     }
     $tbl->getColumns()->get_Item(0)->get_Item(0)->getTextFrame()->setText("00");
     $tbl->getColumns()->get_Item(0)->get_Item(1)->getTextFrame()->setText("01");
     $tbl->getColumns()->get_Item(0)->get_Item(2)->getTextFrame()->setText("02");
     $tbl->getColumns()->get_Item(0)->get_Item(3)->getTextFrame()->setText("03");
     $tbl->getColumns()->get_Item(1)->get_Item(0)->getTextFrame()->setText("10");
     $tbl->getColumns()->get_Item(2)->get_Item(0)->getTextFrame()->setText("20");
     $tbl->getColumns()->get_Item(1)->get_Item(1)->getTextFrame()->setText("11");
     $tbl->getColumns()->get_Item(2)->get_Item(1)->getTextFrame()->setText("21");
     # AddClone adds a row in the end of the table
     $tbl->getRows()->addClone($tbl->getRows()->get_Item(0), false);
     # AddClone adds a column in the end of the table
     $tbl->getColumns()->addClone($tbl->getColumns()->get_Item(0), false);
     # InsertClone adds a row at specific position in a table
     $tbl->getRows()->insertClone(2, $tbl->getRows()->get_Item(0), false);
     # InsertClone adds a row at specific position in a table
     $tbl->getColumns()->insertClone(2, $tbl->getColumns()->get_Item(0), false);
     # Write the presentation as a PPTX file
     $save_format = new SaveFormat();
     $pres->save($dataDir . "CloneRowColumn.pptx", $save_format->Pptx);
     print "Cloned Row & Column from table, please check the output file.";
     PHP_EOL;
 }
Ejemplo n.º 9
0
 public static function remove_slide_by_id($dataDir = null)
 {
     # Instantiate Presentation class that represents the presentation file
     $pres = new Presentation($dataDir . 'Aspose.pptx');
     # Removing a slide using its slide index
     $pres->getSlides()->removeAt(1);
     # Saving the presentation file
     $save_format = new SaveFormat();
     $pres->save($dataDir . "Modified.pptx", $save_format->Pptx);
     print "Removed slide by ID, please check the output file." . PHP_EOL;
 }
Ejemplo n.º 10
0
 public static function run($dataDir = null)
 {
     # Instantiate Presentation class that represents the presentation file
     $pres = new Presentation($dataDir . 'demo.pptx');
     # Removing the hyperlinks from presentation
     $pres->getHyperlinkQueries()->removeAllHyperlinks();
     # Saving the presentation
     $save_format = new SaveFormat();
     $pres->save($dataDir . "Hyperlinks.pptx", $save_format->Pptx);
     print "Removed hyperlinks successfully, please check the output file." . PHP_EOL;
 }
Ejemplo n.º 11
0
 public static function convert_to_html($dataDir = null)
 {
     # Instantiate a Presentation object that represents a PPTX file
     $pres = new Presentation($dataDir . "Aspose.pptx");
     $html_opt = new HtmlOptions();
     $html_formatter = new HtmlFormatter();
     $html_opt->setHtmlFormatter($html_formatter->createDocumentFormatter("", false));
     # Saving the presentation to HTML format
     $save_format = new SaveFormat();
     $pres->save($dataDir . "Aspose.html", $save_format->Html, $html_opt);
     print "Document has been converted, please check the output file.";
 }
Ejemplo n.º 12
0
 public static function run($dataDir = null)
 {
     # Create an instance of Presentation class
     $pres = new Presentation();
     # Setting View Properties of Presentation
     #pres.getViewProperties().getSlideViewProperties().setScale(50) # zoom value in percentages for slide view
     $pres->getViewProperties()->getNotesViewProperties()->setScale(50);
     # .Scale = 50; //zoom value in percentages for notes view
     # Save the presentation as a PPTX file
     $save_format = new SaveFormat();
     $pres->save($dataDir . "Zoom.pptx", $save_format->Pptx);
     print "Set zoom value, please check the output file.";
 }
Ejemplo n.º 13
0
 public static function run($dataDir = null)
 {
     # Instantiate Presentation class that represents the presentation file
     $pres = new Presentation($dataDir . 'Aspose.pptx');
     # Get the slide whose position is to be changed
     $slide = $pres->getSlides()->get_Item(0);
     # Set the new position for the slide
     $slide->setSlideNumber(2);
     # Saving the presentation
     $save_format = new SaveFormat();
     $pres->save($dataDir . "Aspose_Position.pptx", $save_format->Pptx);
     print "Changes slide position, please check the output file." . PHP_EOL;
 }
Ejemplo n.º 14
0
 public static function convert_with_custom_size($dataDir = null)
 {
     # Instantiate a Presentation object that represents a PPTX file
     $pres = new Presentation($dataDir . "Aspose.pptx");
     # Instantiate the TiffOptions class
     $opts = new XpsOptions();
     # Save MetaFiles as PNG
     $opts->SaveMetafilesAsPng = true;
     # Save the presentation to TIFF with specified image size
     $save_format = new SaveFormat();
     $pres->save($dataDir . "Aspose-Custom-Size.xps", $save_format->Xps, $opts);
     print "Document has been converted, please check the output file.";
 }
Ejemplo n.º 15
0
 public static function create_smartart_shape($dataDir = null)
 {
     # Create an instance of Presentation class
     $pres = new Presentation();
     # Get the first slide
     $slide = $pres->getSlides()->get_Item(0);
     # Add Smart Art Shape
     $smartArtLayoutType = new SmartArtLayoutType();
     $smart = $slide->getShapes()->addSmartArt(0, 0, 400, 400, $smartArtLayoutType->BasicBlockList);
     # Write the presentation as a PPTX file
     $saveFormat = new SaveFormat();
     $pres->save($dataDir . "SimpleSmartArt.pptx", $saveFormat->Pptx);
     print "Created smartart shape, please check the output file." . PHP_EOL;
 }
Ejemplo n.º 16
0
 public static function run($dataDir = null)
 {
     # Create an instance of Presentation class
     $pres = new Presentation($dataDir . 'Welcome.pptx');
     # Get the first slide
     $sld = $pres->getSlides()->get_Item(0);
     # Change the text of each placeholder
     $shp = $sld->getShapes()->get_Item(0);
     $shp->getTextFrame()->setText("This is Placeholder");
     # Write the presentation as a PPTX file
     $save_format = new SaveFormat();
     $pres->save($dataDir . "Welcome_PH.pptx", $save_format->Pptx);
     print "Replaced text, please check the output file." . PHP_EOL;
 }
Ejemplo n.º 17
0
 public static function run($dataDir = null)
 {
     # Instantiate Presentation class that represents the presentation file
     $pres = new Presentation($dataDir . 'demo.pptx');
     $transition_type = new TransitionType();
     # Apply circle type transition on slide 1
     $pres->getSlides()->get_Item(0)->getSlideShowTransition()->setType($transition_type->Circle);
     # Apply comb type transition on slide 2
     $pres->getSlides()->get_Item(1)->getSlideShowTransition()->setType($transition_type->Comb);
     # Saving the presentation
     $save_format = new SaveFormat();
     $pres->save($dataDir . "SimpleTransition.pptx", $save_format->Pptx);
     print "Done with simple transition, please check the output file." . PHP_EOL;
 }
Ejemplo n.º 18
0
 public static function run($dataDir = null)
 {
     # Create an instance of Presentation class
     $pres = new Presentation();
     # Adding the Media Player ActiveX control
     $controlType = new ControlType();
     $pres->getSlides()->get_Item(0)->getControls()->addControl($controlType->WindowsMediaPlayer, 100, 100, 400, 400);
     # Access the Media Player ActiveX control and set the video path
     $pres->getSlides()->get_Item(0)->getControls()->get_Item(0)->getProperties()->set_Item("URL", $dataDir . "Wildlife.mp4");
     # Write the presentation as a PPTX file
     $saveFormat = new SaveFormat();
     $pres->save($dataDir . "AddActiveX.pptx", $saveFormat->Pptx);
     print "Added ActiveX control, please check the output file." . PHP_EOL;
 }
Ejemplo n.º 19
0
 public static function remove_property($dataDir = null)
 {
     # Instantiate the Presentation class that represents the presentation
     $pres = new Presentation($dataDir . "HelloWorld.pptx");
     # Getting Document Properties
     $dp = $pres->getDocumentProperties();
     # Getting property name at particular index
     $property_name = $dp->getPropertyName(2);
     # Removing selected property
     $dp->remove($property_name);
     # Saving presentation
     $save_format = new SaveFormat();
     $pres->save($dataDir . "RemoveDP.pptx", $save_format->Pptx);
     print "Remove document property, please check output file.";
 }
Ejemplo n.º 20
0
 public static function run($dataDir = null)
 {
     $pres = new Presentation();
     # Get the first slide
     $slide = $pres->getSlides()->get_Item(0);
     $col_width = [100, 50, 30];
     $row_height = [30, 50, 30];
     $table = $slide->getShapes()->addTable(100, 100, $col_width, $row_height);
     $table->getRows()->removeAt(1, false);
     $table->getColumns()->removeAt(1, false);
     # Write the presentation as a PPTX file
     $save_format = new SaveFormat();
     $pres->save($dataDir . "RemoveRowColumn.pptx", $save_format->Pptx);
     print "Removed Row & Column from table, please check the output file." . PHP_EOL;
 }
Ejemplo n.º 21
0
 public static function set_page_size_for_pdf($dataDir = null)
 {
     # Instantiate Presentation class that represents the presentation file
     $pres = new Presentation();
     # Set SlideSize.Type Property
     $slideSizeType = new SlideSizeType();
     $pres->getSlideSize()->setType($slideSizeType->A4Paper);
     # Set different properties of PDF Options
     $opts = new PdfOptions();
     $opts->setSufficientResolution(600);
     # Saving the presentation
     $save_format = new SaveFormat();
     $pres->save($dataDir . "Export.pdf", $save_format->Pdf, $opts);
     print "Set page size for pdf, please check the output file." . PHP_EOL;
 }
Ejemplo n.º 22
0
 public static function run($dataDir = null)
 {
     # Create an instance of Presentation class
     $pres = new Presentation();
     # Get the first slide
     $sld = $pres->getSlides()->get_Item(0);
     # Add autoshape of rectangle type
     $shapeType = new ShapeType();
     $shp = $sld->getShapes()->addAutoShape($shapeType->Rectangle, 50, 150, 75, 150);
     # Rotate the shape to 90 degree
     $shp->setRotation(90);
     # Write the presentation as a PPTX file
     $save_format = new SaveFormat();
     $pres->save($dataDir . "RectShpRot.pptx", $save_format->Pptx);
     print "Rotated shape, please check the output file." . PHP_EOL;
 }
Ejemplo n.º 23
0
 public static function run($dataDir = null)
 {
     # Instantiate Presentation class that represents the presentation file
     $pres = new Presentation();
     # Access first slide
     $sld = $pres->getSlides()->get_Item(0);
     # Adding a chart on slide
     $chartType = new ChartType();
     $ch = $sld->getShapes()->addChart($chartType->ClusteredColumn, 20, 20, 500, 300);
     # Setting the position of label from axis
     $ch->getAxes()->getHorizontalAxis()->setLabelOffset(500);
     # Saving the presentation
     $save_format = new SaveFormat();
     $pres->save($dataDir . "Position.pptx", $save_format->Pptx);
     print "Set label distance, please check the output file." . PHP_EOL;
 }
Ejemplo n.º 24
0
 public static function run($dataDir = null)
 {
     # Instantiate Presentation class that represents the presentation file
     $pres = new Presentation($dataDir . "AsposeChart.pptx");
     # Access first slide
     $sld = $pres->getSlides()->get_Item(0);
     # Add chart with default data
     $chart = $sld->getShapes()->get_Item(0);
     # Setting the index of chart data sheet
     $defaultWorksheetIndex = 0;
     # Getting the chart data worksheet
     $fact = $chart->getChartData()->getChartDataWorkbook();
     # Changing chart Category Name
     $fact->getCell($defaultWorksheetIndex, 1, 0, "Modified Category 1");
     $fact->getCell($defaultWorksheetIndex, 2, 0, "Modified Category 2");
     # Take first chart series
     $series = $chart->getChartData()->getSeries()->get_Item(0);
     # Now updating series data
     $fact->getCell($defaultWorksheetIndex, 0, 1, "New_Series1");
     # modifying series name
     $series->getDataPoints()->get_Item(0)->getValue()->setData(90);
     $series->getDataPoints()->get_Item(1)->getValue()->setData(123);
     $series->getDataPoints()->get_Item(2)->getValue()->setData(44);
     # Take Second chart series
     $series = $chart->getChartData()->getSeries()->get_Item(1);
     # Now updating series data
     $fact->getCell($defaultWorksheetIndex, 0, 2, "New_Series2");
     #modifying series name
     $series->getDataPoints()->get_Item(0)->getValue()->setData(23);
     $series->getDataPoints()->get_Item(1)->getValue()->setData(67);
     $series->getDataPoints()->get_Item(2)->getValue()->setData(99);
     # Now, Adding a new series
     $chart->getChartData()->getSeries()->add($fact->getCell($defaultWorksheetIndex, 0, 3, "Series 3"), $chart->getType());
     # Take 3rd chart series
     $series = $chart->getChartData()->getSeries()->get_Item(2);
     # Now populating series data
     $series->getDataPoints()->addDataPointForBarSeries($fact->getCell($defaultWorksheetIndex, 1, 3, 20));
     $series->getDataPoints()->addDataPointForBarSeries($fact->getCell($defaultWorksheetIndex, 2, 3, 50));
     $series->getDataPoints()->addDataPointForBarSeries($fact->getCell($defaultWorksheetIndex, 3, 3, 30));
     $chartType = new ChartType();
     $chart->setType($chartType->ClusteredCylinder);
     # Saving the presentation to HTML format
     $save_format = new SaveFormat();
     $pres->save($dataDir . "AsposeChartModified.pptx", $save_format->Pptx);
     print "Updated chart, please check the output file." . PHP_EOL;
 }
Ejemplo n.º 25
0
 public static function add_overlap_for_chart($dataDir = null)
 {
     # Instantiate Presentation class that represents the presentation file
     $pres = new Presentation();
     # Adding chart
     $chartType = new ChartType();
     $chart = $pres->getSlides()->get_Item(0)->getShapes()->addChart($chartType->ClusteredColumn, 50, 50, 600, 400, true);
     $series = $chart->getChartData()->getSeries();
     if ($series->get_Item(0)->getOverlap() == 0) {
         # Setting series overlap
         $series->get_Item(0)->getParentSeriesGroup()->setOverlap(-30);
     }
     # Saving the presentation
     $save_format = new SaveFormat();
     $pres->save($dataDir . "Overlap.pptx", $save_format->Pptx);
     print "Added chart series overlap for charts, please check the output file." . PHP_EOL;
 }
Ejemplo n.º 26
0
 public static function run($dataDir = null)
 {
     # Instantiate Presentation class that represents the presentation file
     $pres = new Presentation();
     # Instantiate SlideCollection calss
     $slides = $pres->getSlides();
     $i = 0;
     while ($i < $pres->getLayoutSlides()->size()) {
         # Add an empty slide to the Slides collection
         $slides->addEmptySlide($pres->getLayoutSlides()->get_Item($i));
         $i += 1;
     }
     #Do some work on the newly added slide
     # Saving the presentation
     $save_format = new SaveFormat();
     $pres->save($dataDir . "EmptySlide.pptx", $save_format->Pptx);
     print "Document has been created, please check the output file.";
 }
Ejemplo n.º 27
0
 public static function add_video_frame($dataDir = null)
 {
     # Create an instance of Presentation class
     $pres = new Presentation();
     # Get the first slide
     $sId = $pres->getSlides()->get_Item(0);
     # Add Video Frame
     $vf = $sId->getShapes()->addVideoFrame(50, 150, 300, 150, $dataDir . "Wildlife.mp4");
     # Set Play Mode and Volume of the Video
     $videoPlayModePreset = new VideoPlayModePreset();
     $audioVolumeMode = new AudioVolumeMode();
     $vf->setPlayMode($videoPlayModePreset->Auto);
     $vf->setVolume($audioVolumeMode->Loud);
     # Write the presentation as a PPTX file
     $save_format = new SaveFormat();
     $pres->save($dataDir . "VideoFrame.pptx", $save_format->Pptx);
     print "Added video frame to slide, please check the output file." . PHP_EOL;
 }
Ejemplo n.º 28
0
 public static function set_location_and_size($dataDir = null)
 {
     # Creating empty presentation
     $pres = new Presentation();
     # Get reference of the slide
     $slide = $pres->getSlides()->get_Item(0);
     # Add a clustered column chart on the slide
     $chartType = new ChartType();
     $chart = $slide->getShapes()->addChart($chartType->ClusteredColumn, 50, 50, 500, 500);
     # Set Legend Properties
     $chart->getLegend()->setX(50 / $chart->getWidth());
     $chart->getLegend()->setY(50 / $chart->getHeight());
     $chart->getLegend()->setWidth(100 / $chart->getWidth());
     $chart->getLegend()->setHeight(100 / $chart->getHeight());
     # Saving the presentation
     $save_format = new SaveFormat();
     $pres->save($dataDir . "Legend.pptx", $save_format->Pptx);
     print "Set custom location and size of chart legend, please check the output file." . PHP_EOL;
 }
Ejemplo n.º 29
0
 public static function run($dataDir = null)
 {
     # Creating empty presentation
     $pres = new Presentation();
     # Creating a clustered column chart
     $chartType = new ChartType();
     $chart = $pres->getSlides()->get_Item(0)->getShapes()->addChart($chartType->ClusteredColumn, 20, 20, 500, 400);
     # Adding ponential trend line for chart series 1
     $trendlineType = new TrendlineType();
     $tredLinep = $chart->getChartData()->getSeries()->get_Item(0)->getTrendLines()->add($trendlineType->Exponential);
     $tredLinep->setDisplayEquation(false);
     $tredLinep->setDisplayRSquaredValue(false);
     # Adding Linear trend line for chart series 1
     $fillType = new FillType();
     $color = new Color();
     $tredLineLin = $chart->getChartData()->getSeries()->get_Item(0)->getTrendLines()->add($trendlineType->Linear);
     $tredLineLin->setTrendlineType($trendlineType->Linear);
     $tredLineLin->getFormat()->getLine()->getFillFormat()->setFillType($fillType->Solid);
     $tredLineLin->getFormat()->getLine()->getFillFormat()->getSolidFillColor()->setColor($color->RED);
     # Adding Logarithmic trend line for chart series 2
     $tredLineLog = $chart->getChartData()->getSeries()->get_Item(1)->getTrendLines()->add($trendlineType->Logarithmic);
     $tredLineLog->setTrendlineType($trendlineType->Logarithmic);
     $tredLineLog->addTextFrameForOverriding("New log trend line");
     # Adding MovingAverage trend line for chart series 2
     $tredLineMovAvg = $chart->getChartData()->getSeries()->get_Item(1)->getTrendLines()->add($trendlineType->MovingAverage);
     $tredLineMovAvg->setTrendlineType($trendlineType->MovingAverage);
     $tredLineMovAvg->setPeriod(3);
     $tredLineMovAvg->setTrendlineName("New TrendLine Name");
     # Adding Polynomial trend line for chart series 3
     $tredLinePol = $chart->getChartData()->getSeries()->get_Item(2)->getTrendLines()->add($trendlineType->Polynomial);
     $tredLinePol->setTrendlineType($trendlineType->Polynomial);
     $tredLinePol->setForward(1);
     $tredLinePol->setOrder(3);
     # Adding Power trend line for chart series 3
     $tredLinePower = $chart->getChartData()->getSeries()->get_Item(1)->getTrendLines()->add($trendlineType->Power);
     $tredLinePower->setTrendlineType($trendlineType->Power);
     $tredLinePower->setBackward(1);
     # Saving the presentation
     $save_format = new SaveFormat();
     $pres->save($dataDir . "ChartTrendLines.pptx", $save_format->Pptx);
     print "Done with chart trend lines, please check the output file." . PHP_EOL;
 }
Ejemplo n.º 30
0
 public static function run($dataDir = null)
 {
     $pres = new Presentation();
     # Get the first slide
     $sld = $pres->getSlides()->get_Item(0);
     # Define columns with widths and rows with heights
     $dblCols = [50, 50, 50];
     $dblRows = [50, 30, 30, 30, 30];
     # Add table shape to slide
     $tbl = $sld->getShapes()->addTable(100, 50, $dblCols, $dblRows);
     $fill_type = new FillType();
     $color = new Color();
     # Set border format for each cell
     $row = 0;
     while ($row < java_values($tbl->getRows()->size())) {
         $cell = 0;
         while ($cell < $tbl->getRows()->get_Item($row)->size()) {
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderTop()->getFillFormat()->setFillType($fill_type->Solid);
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderTop()->getFillFormat()->getSolidFillColor()->setColor($color->RED);
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderTop()->setWidth(5);
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderBottom()->getFillFormat()->setFillType($fill_type->Solid);
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderBottom()->getFillFormat()->getSolidFillColor()->setColor($color->RED);
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderBottom()->setWidth(5);
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderLeft()->getFillFormat()->setFillType($fill_type->Solid);
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderLeft()->getFillFormat()->getSolidFillColor()->setColor($color->RED);
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderLeft()->setWidth(5);
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderRight()->getFillFormat()->setFillType($fill_type->Solid);
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderRight()->getFillFormat()->getSolidFillColor()->setColor($color->RED);
             $tbl->getRows()->get_Item($row)->get_Item($cell)->getBorderRight()->setWidth(5);
             $cell++;
         }
         $row++;
     }
     # Merge cells 1 & 2 of row 1
     $tbl->mergeCells($tbl->getRows()->get_Item(0)->get_Item(0), $tbl->getRows()->get_Item(1)->get_Item(0), false);
     # Add text to the merged cell
     $tbl->getRows()->get_Item(0)->get_Item(0)->getTextFrame()->setText("Merged Cells");
     # Write the presentation as a PPTX file
     $save_format = new SaveFormat();
     $pres->save($dataDir . "CreateTable.pptx", $save_format->Pptx);
     print "Created table, please check the output file." . PHP_EOL;
 }