def __init__(self): dataDir = Settings.dataDir + 'WorkingWithTables/AddImage/' pres = 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 = ImageIO() image = imageIO.read(File(dataDir + "aspose-logo.jpg")) imgx1 = pres.getImages().addImage(image) fillType=FillType() pictureFillMode=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 = SaveFormat() pres.save(dataDir + "AddImage.pptx", save_format.Pptx) print "Added image, please check the output file."
def fill_shapes_with_picture(dataDir): dataDir = Settings.dataDir + 'WorkingWithShapes/FillingShapes/' # Create an instance of Presentation class pres = Presentation() # Get the first slide sld = pres.getSlides().get_Item(0) # Add autoshape of rectangle type shapeType = ShapeType shp = sld.getShapes().addAutoShape(shapeType.Rectangle, 50, 150, 75, 150) # Set the fill type to Picture fillType = FillType shp.getFillFormat().setFillType(fillType.Picture) # Set the picture fill mode pictureFillMode = PictureFillMode shp.getFillFormat().getPictureFillFormat().setPictureFillMode( pictureFillMode.Tile) # Set the picture imgx = pres.getImages().addImage( FileInputStream(File(dataDir + "night.jpg"))) shp.getFillFormat().getPictureFillFormat().getPicture().setImage(imgx) # Write the presentation as a PPTX file save_format = SaveFormat pres.save(dataDir + "RectShpPic.pptx", save_format.Pptx) print "Filled shapes with Picture, please check the output file."
def set_image_as_background_color(dataDir): dataDir = Settings.dataDir + 'WorkingWithSlidesInPresentation/Background/' # Instantiate Presentation class that represents the presentation file pres = Presentation() # Set the background with Image backgroundType = BackgroundType fillType = FillType pictureFillMode = 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(FileInputStream(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 = SaveFormat pres.save(dataDir + "ContentBG_Image.pptx", save_format.Pptx) print "Set image as background, please check the output file."
def set_image_as_background_color(dataDir): dataDir = Settings.dataDir + 'WorkingWithSlidesInPresentation/Background/' # Instantiate Presentation class that represents the presentation file pres = Presentation() # Set the background with Image backgroundType = BackgroundType fillType = FillType pictureFillMode = 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( FileInputStream(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 = SaveFormat pres.save(dataDir + "ContentBG_Image.pptx", save_format.Pptx) print "Set image as background, please check the output file."
def fill_shapes_with_picture(dataDir): dataDir = Settings.dataDir + 'WorkingWithShapes/FillingShapes/' # Create an instance of Presentation class pres = Presentation() # Get the first slide sld = pres.getSlides().get_Item(0) # Add autoshape of rectangle type shapeType = ShapeType shp = sld.getShapes().addAutoShape(shapeType.Rectangle, 50, 150, 75, 150) # Set the fill type to Picture fillType = FillType shp.getFillFormat().setFillType(fillType.Picture) # Set the picture fill mode pictureFillMode = PictureFillMode shp.getFillFormat().getPictureFillFormat().setPictureFillMode(pictureFillMode.Tile) # Set the picture imgx = pres.getImages().addImage(FileInputStream(File(dataDir + "night.jpg"))) shp.getFillFormat().getPictureFillFormat().getPicture().setImage(imgx) # Write the presentation as a PPTX file save_format = SaveFormat pres.save(dataDir + "RectShpPic.pptx", save_format.Pptx) print "Filled shapes with Picture, please check the output file."
def add_picture_frame(dataDir): dataDir = Settings.dataDir + 'WorkingWithShapes/Frame/' # Create an instance of Presentation class pres = Presentation() # Get the first slide sId = pres.getSlides().get_Item(0) # Instantiate the Image class imgx = pres.getImages().addImage( FileInputStream(File(dataDir + "aspose-logo.jpg"))) # Add Picture Frame with height and width equivalent of Picture shapeType = ShapeType sId.getShapes().addPictureFrame(shapeType.Rectangle, 50, 150, imgx.getWidth(), imgx.getHeight(), imgx) # Write the presentation as a PPTX file save_format = SaveFormat pres.save(dataDir + "RectPicFrame.pptx", save_format.Pptx) print "Added picture frame to slide, please check the output file."
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithTables/AddImage/' pres = 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 = ImageIO() image = imageIO.read(File(dataDir + "aspose-logo.jpg")) imgx1 = pres.getImages().addImage(image) fillType=FillType() pictureFillMode=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 = SaveFormat() pres.save(dataDir + "AddImage.pptx", save_format.Pptx) print "Added image, please check the output file."
def add_picture_frame(dataDir): dataDir = Settings.dataDir + 'WorkingWithShapes/Frame/' # Create an instance of Presentation class pres = Presentation() # Get the first slide sId = pres.getSlides().get_Item(0) # Instantiate the Image class imgx = pres.getImages().addImage(FileInputStream(File(dataDir + "aspose-logo.jpg"))) # Add Picture Frame with height and width equivalent of Picture shapeType = ShapeType sId.getShapes().addPictureFrame(shapeType.Rectangle, 50, 150, imgx.getWidth(), imgx.getHeight(), imgx) # Write the presentation as a PPTX file save_format = SaveFormat pres.save(dataDir + "RectPicFrame.pptx", save_format.Pptx) print "Added picture frame to slide, please check the output file."