Example #1
0
 public static function add_picture_frame($dataDir = null)
 {
     # Create an instance of Presentation class
     $pres = new Presentation();
     # Get the first slide
     $sId = $pres->getSlides()->get_Item(0);
     # Instantiate the Image class
     $imgx = $pres->getImages()->addImage(new FileInputStream(new File($dataDir . "aspose-logo.jpg")));
     # Add Picture Frame with height and width equivalent of Picture
     $shapeType = new ShapeType();
     $sId->getShapes()->addPictureFrame($shapeType->Rectangle, 50, 150, $imgx->getWidth(), $imgx->getHeight(), $imgx);
     # Write the presentation as a PPTX file
     $save_format = new SaveFormat();
     $pres->save($dataDir . "RectPicFrame.pptx", $save_format->Pptx);
     print "Added picture frame to slide, please check the output file." . PHP_EOL;
 }
 public static function set_image_as_background_color($dataDir = null)
 {
     # Instantiate Presentation class that represents the presentation file
     $pres = new Presentation();
     # Set the background with Image
     $backgroundType = new BackgroundType();
     $fillType = new FillType();
     $pictureFillMode = new PictureFillMode();
     $pres->getSlides()->get_Item(0)->getBackground()->setType($backgroundType->OwnBackground);
     $pres->getSlides()->get_Item(0)->getBackground()->getFillFormat()->setFillType($fillType->Picture);
     $pres->getSlides()->get_Item(0)->getBackground()->getFillFormat()->getPictureFillFormat()->setPictureFillMode($pictureFillMode->Stretch);
     # Set the picture
     $imgx = $pres->getImages()->addImage(new FileInputStream(new File($dataDir . 'night.jpg')));
     # Image imgx = pres.getImages().addImage(image);
     # Add image to presentation's images collection
     $pres->getSlides()->get_Item(0)->getBackground()->getFillFormat()->getPictureFillFormat()->getPicture()->setImage($imgx);
     # Saving the presentation
     $save_format = new SaveFormat();
     $pres->save($dataDir . "ContentBG_Image.pptx", $save_format->Pptx);
     print "Set image as background, please check the output file." . PHP_EOL;
 }
 public static function fill_shapes_with_picture($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);
     # Set the fill type to Picture
     $fillType = new FillType();
     $shp->getFillFormat()->setFillType($fillType->Picture);
     # Set the picture fill mode
     $pictureFillMode = new PictureFillMode();
     $shp->getFillFormat()->getPictureFillFormat()->setPictureFillMode($pictureFillMode->Tile);
     # Set the picture
     $imgx = $pres->getImages()->addImage(new FileInputStream(new File($dataDir . "night.jpg")));
     $shp->getFillFormat()->getPictureFillFormat()->getPicture()->setImage($imgx);
     # Write the presentation as a PPTX file
     $save_format = new SaveFormat();
     $pres->save($dataDir . "RectShpPic.pptx", $save_format->Pptx);
     print "Filled shapes with Picture, please check the output file." . PHP_EOL;
 }
Example #4
0
 public static function run($dataDir = null)
 {
     $pres = new Presentation();
     # Get the first slide
     $sld = $pres->getSlides()->get_Item(0);
     # Define co lumns with widths and rows with heights
     $dbl_cols = [150, 150, 150, 150];
     $dbl_rows = [100, 100, 100, 100, 90];
     # Add table shape to slide
     $tbl = $sld->getShapes()->addTable(50, 50, $dbl_cols, $dbl_rows);
     # Creating a Buffered Image object to hold the image file
     $imageIO = new ImageIO();
     $image = $imageIO->read(new File($dataDir . "aspose-logo.jpg"));
     $imgx1 = $pres->getImages()->addImage($image);
     $fillType = new FillType();
     $pictureFillMode = new PictureFillMode();
     $tbl->get_Item(0, 0)->getFillFormat()->setFillType($fillType->Picture);
     $tbl->get_Item(0, 0)->getFillFormat()->getPictureFillFormat()->setPictureFillMode($pictureFillMode->Stretch);
     $tbl->get_Item(0, 0)->getFillFormat()->getPictureFillFormat()->getPicture()->setImage($imgx1);
     # Write the presentation as a PPTX file
     $save_format = new SaveFormat();
     $pres->save($dataDir . "AddImage.pptx", $save_format->Pptx);
     print "Added image, please check the output file." . PHP_EOL;
 }