def add_video_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) # Add Video Frame vf = sId.getShapes().addVideoFrame(50, 150, 300, 150, dataDir + "Wildlife.mp4") # Set Play Mode and Volume of the Video videoPlayModePreset = VideoPlayModePreset audioVolumeMode = AudioVolumeMode vf.setPlayMode(videoPlayModePreset.Auto) vf.setVolume(audioVolumeMode.Loud) # Write the presentation as a PPTX file save_format = SaveFormat pres.save(dataDir + "VideoFrame.pptx", save_format.Pptx) print "Added video frame to slide, please check the output file."
def get_properties(dataDir): dataDir = Settings.dataDir + 'WorkingWithPresentation/Properties/' # Instantiate the Presentation class that represents the presentation pres = Presentation(dataDir + "HelloWorld.pptx") # Create a reference to IDocumentProperties object associated with Presentation dp = pres.getDocumentProperties() # Display the builtin properties print "Category : " + dp.getCategory() print "Current Status : " + dp.getContentStatus() print "Creation Date : " dp.getCreatedTime() print "Author : " + dp.getAuthor() print "Description : " + dp.getComments() print "KeyWords : " + dp.getKeywords() print "Last Modified By : " + dp.getLastSavedBy() print "Supervisor : " + dp.getManager() print "Modified Date : " dp.getLastSavedTime() print "Presentation Format : " dp.getPresentationFormat() print "Last Print Date : " dp.getLastPrinted() print "Is Shared between producers : " dp.getSharedDoc() print "Subject : " dp.getSubject() print "Title : " dp.getTitle()
def fill_shapes_with_solid_color(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 Solid fillType = FillType shp.getFillFormat().setFillType(fillType.Solid) # Set the color of the rectangle color = Color shp.getFillFormat().getSolidFillColor().setColor(color.YELLOW) # Write the presentation as a PPTX file save_format = SaveFormat pres.save(dataDir + "RectShpSolid.pptx", save_format.Pptx) print "Filled shapes with Solid Color, please check the output file."
def convert_with_custom_size(dataDir): dataDir = Settings.dataDir + 'WorkingWithPresentation/ConvertingToTiff/' # Instantiate a Presentation object that represents a PPTX file pres = Presentation(dataDir + "Aspose.pptx") # Instantiate the TiffOptions class opts = TiffOptions # Setting compression type tiff_compression_types = TiffCompressionTypes opts.setCompressionType(tiff_compression_types.Default) #Setting image DPI opts.setDpiX(200) opts.setDpiY(100) # Set Image Size opts.setImageSize(Dimension(1728, 1078)) # Save the presentation to TIFF with specified image size save_format = SaveFormat pres.save(dataDir + "Aspose-Custom-Size.tiff", save_format.Tiff, opts) print "Document has been converted, please check the output file."
def __init__(self): dataDir = Settings.dataDir + 'IntroductionToPresentation/HelloWorld' # Instantiate Presentation pres = Presentation() # Get the first slide slide = pres.getSlides().get_Item(0) # Add an AutoShape of Rectangle type shape_type = 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 = FillType color = 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 = SaveFormat pres.save(dataDir + "HelloWorld.pptx", save_format.Pptx) print "Document has been saved, 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 __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_fixed_error_bar_value(dataDir): dataDir = Settings.dataDir + 'WorkingWithCharts/ErrorBars' pres = Presentation() # Creating a bubble chart chartType = ChartType chart = pres.getSlides().get_Item(0).getShapes().addChart( chartType.Bubble, 50, 50, 400, 300, True) # Adding Error bars and setting its format error_bar_x = chart.getChartData().getSeries().get_Item( 0).getErrorBarsXFormat() error_bar_y = chart.getChartData().getSeries().get_Item( 0).getErrorBarsYFormat() errorBarValueType = ErrorBarValueType errorBarType = ErrorBarType error_bar_x.setValueType(errorBarValueType.Fixed) error_bar_x.setValue(0.1) error_bar_y.setValueType(errorBarValueType.Percentage) error_bar_y.setValue(5) error_bar_x.setType(errorBarType.Plus) error_bar_y.getFormat().getLine().setWidth(2.0) #error_bar_x.hasEndCap(True) # Save presentation with chart save_format = SaveFormat pres.save(dataDir + "ErrorBar.pptx", save_format.Pptx) print "Added fixed error bar value for chart, please check the output file."
def create_textbox_with_hyperlink(dataDir): dataDir = Settings.dataDir + 'WorkingWithText/CreateTextBox/' pres = Presentation() # Get the first slide sld = pres.getSlides().get_Item(0) # Add autoshape of rectangle type shapeType=ShapeType pptxShape = sld.getShapes().addAutoShape(shapeType.Rectangle, 150, 150, 150, 50) # Cast the shape to AutoShape pptxAutoShape = pptxShape # Access ITextFrame associated with the AutoShape pptxAutoShape.addTextFrame("") text_frame = pptxAutoShape.getTextFrame() # Add some text to the frame text_frame.getParagraphs().get_Item(0).getPortions().get_Item(0).setText("Aspose.Slides") #Set Hyperlink for the portion text hypman = text_frame.getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().getHyperlinkManager() hypman.setExternalHyperlinkClick("http://www.aspose.com") # Write the presentation as a PPTX file save_format =SaveFormat pres.save(dataDir + "hLinkPPTX.pptx", save_format.Pptx) print "Created TextBox with Hyperlink, please check the output file."
def add_fixed_error_bar_value(dataDir): dataDir = Settings.dataDir + 'WorkingWithCharts/ErrorBars' pres = Presentation() # Creating a bubble chart chartType=ChartType chart = pres.getSlides().get_Item(0).getShapes().addChart(chartType.Bubble, 50, 50, 400, 300, True) # Adding Error bars and setting its format error_bar_x = chart.getChartData().getSeries().get_Item(0).getErrorBarsXFormat() error_bar_y = chart.getChartData().getSeries().get_Item(0).getErrorBarsYFormat() errorBarValueType = ErrorBarValueType errorBarType = ErrorBarType error_bar_x.setValueType(errorBarValueType.Fixed) error_bar_x.setValue(0.1) error_bar_y.setValueType(errorBarValueType.Percentage) error_bar_y.setValue(5) error_bar_x.setType(errorBarType.Plus) error_bar_y.getFormat().getLine().setWidth(2.0) #error_bar_x.hasEndCap(True) # Save presentation with chart save_format = SaveFormat pres.save(dataDir + "ErrorBar.pptx", save_format.Pptx) print "Added fixed error bar value for chart, please check the output file."
def create_smartart_shape(dataDir): dataDir = Settings.dataDir + 'WorkingWithSmartArt/FillFormat/' # Create an instance of Presentation class pres = Presentation() # Get the first slide slide = pres.getSlides().get_Item(0) # Adding SmartArt shape and nodes smartArtLayoutType = SmartArtLayoutType chevron = slide.getShapes().addSmartArt( 10, 10, 800, 60, smartArtLayoutType.ClosedChevronProcess) node = chevron.getAllNodes().addNode() node.getTextFrame().setText("Some text") # Setting node fill color color = Color fillType = FillType item = node.getShapes().get_Item(0) item.getFillFormat().setFillType(fillType.Solid) item.getFillFormat().getSolidFillColor().setColor(color.RED) # Write the presentation as a PPTX file saveFormat = SaveFormat pres.save(dataDir + "FillFormat.pptx", saveFormat.Pptx) print "Set fill format for smartart node, please check the output file."
def fill_shapes_with_pattern(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 Pattern fillType = FillType shp.getFillFormat().setFillType(fillType.Pattern) # Set the pattern style patternStyle = PatternStyle shp.getFillFormat().getPatternFormat().setPatternStyle(patternStyle.Trellis) # Set the pattern back and fore colors color = Color shp.getFillFormat().getPatternFormat().getBackColor().setColor(color.LIGHT_GRAY) shp.getFillFormat().getPatternFormat().getForeColor().setColor(color.YELLOW) # Write the presentation as a PPTX file save_format = SaveFormat pres.save(dataDir + "RectShpPatt.pptx", save_format.Pptx) print "Filled shapes with Pattern, please check the output file."
def create_thumbnail_in_notes_slides_view(dataDir): # Instantiate Presentation class that represents the presentation file pres = Presentation(dataDir + 'demo.pptx') # Access the first slide slide = pres.getSlides().get_Item(0) # User defined dimension desired_x = 1200 desired_y = 800 # Getting scaled value of X and Y scale_x = (1.0 / java_values( pres.getSlideSize().getSize().getWidth())) * desired_x scale_y = (1.0 / java_values( pres.getSlideSize().getSize().getHeight())) * desired_y # Create a full scale image image = slide.getNotesSlide().getThumbnail(scale_x, scale_y) # Save the image to disk in JPEG format imageIO = ImageIO() imageIO.write(image, "jpeg", File(dataDir + "ContentBG_tnail.jpg")) print "Created thumbnail in notes slides view, please check the output file.".PHP_EOL
def create_smartart_shape(dataDir): dataDir = Settings.dataDir + 'WorkingWithSmartArt/FillFormat/' # Create an instance of Presentation class pres =Presentation() # Get the first slide slide = pres.getSlides().get_Item(0) # Adding SmartArt shape and nodes smartArtLayoutType=SmartArtLayoutType chevron = slide.getShapes().addSmartArt(10, 10, 800, 60, smartArtLayoutType.ClosedChevronProcess) node = chevron.getAllNodes().addNode() node.getTextFrame().setText("Some text") # Setting node fill color color=Color fillType=FillType item = node.getShapes().get_Item(0) item.getFillFormat().setFillType(fillType.Solid) item.getFillFormat().getSolidFillColor().setColor(color.RED) # Write the presentation as a PPTX file saveFormat=SaveFormat pres.save(dataDir + "FillFormat.pptx", saveFormat.Pptx) print "Set fill format for smartart node, please check the output file."
def set_background_color_of_normal_slide(dataDir): dataDir = Settings.dataDir + 'WorkingWithSlidesInPresentation/Background/' # Instantiate Presentation class that represents the presentation file pres = Presentation() # Set the background color of the Normal slide to Blue backgroundType = BackgroundType fillType = FillType color = Color pres.getSlides().get_Item(0).getBackground().setType( backgroundType.OwnBackground) pres.getSlides().get_Item( 0).getBackground().getFillFormat().setFillType(fillType.Solid) pres.getSlides().get_Item( 0).getBackground().getFillFormat().getSolidFillColor().setColor( color.BLUE) # Saving the presentation save_format = SaveFormat pres.save(dataDir + "ContentBG.pptx", save_format.Pptx) print "Set background color of normal slide, please check the output file."
def create_thumbnail_custom_size(dataDir): # Instantiate Presentation class that represents the presentation file pres = Presentation(dataDir + 'demo.pptx') # Access the first slide slide = pres.getSlides().get_Item(0) # User defined dimension desired_x = 1200 desired_y = 800 # Getting scaled value of X and Y scale_x = (1.0 / java_values(pres.getSlideSize().getSize().getWidth())) * desired_x scale_y = (1.0 / java_values(pres.getSlideSize().getSize().getHeight())) * desired_y # Create a full scale image image = slide.getThumbnail(scale_x, scale_y) # Save the image to disk in JPEG format imageIO = ImageIO() imageIO.write(image, "jpeg", File(dataDir + "ContentBG_tnail.jpg")) print "Created thumbnail with custom size, please check the output file.". PHP_EOL
def add_audio_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) # Load the wav sound file to stram fstr = FileInputStream(File(dataDir + "Bass-Drum.wav")) # Add Audio Frame af = sId.getShapes().addAudioFrameEmbedded(50, 150, 100, 100, fstr) # Set Play Mode and Volume of the Audio audioPlayModePreset = AudioPlayModePreset audioVolumeMode = AudioVolumeMode af.setPlayMode(audioPlayModePreset.Auto) af.setVolume(audioVolumeMode.Loud) # Write the presentation as a PPTX file save_format = SaveFormat pres.save(dataDir + "AudioFrameEmbed.pptx", save_format.Pptx) print "Added audio frame to slide, please check the output file."
def convert_with_custom_size(dataDir): dataDir = Settings.dataDir + 'WorkingWithPresentation/ConvertingToTiff/' # Instantiate a Presentation object that represents a PPTX file pres = Presentation(dataDir + "Aspose.pptx") # Instantiate the TiffOptions class opts = TiffOptions # Setting compression type tiff_compression_types = TiffCompressionTypes opts.setCompressionType (tiff_compression_types.Default) #Setting image DPI opts.setDpiX(200) opts.setDpiY(100) # Set Image Size opts.setImageSize(Dimension(1728, 1078)) # Save the presentation to TIFF with specified image size save_format = SaveFormat pres.save(dataDir + "Aspose-Custom-Size.tiff", save_format.Tiff,opts) print "Document has been converted, please check the output file."
def create_textbox(dataDir): dataDir = Settings.dataDir + 'WorkingWithText/CreateTextBox/' # 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, 150, 75, 150, 50) # Add TextFrame to the Rectangle shp.addTextFrame(" ") # Accessing the text frame txt_frame = shp.getTextFrame() # Create the Paragraph object for text frame para = txt_frame.getParagraphs().get_Item(0) # Create Portion object for paragraph portion = para.getPortions().get_Item(0) # Set Text portion.setText("Aspose TextBox") # Write the presentation as a PPTX file save_format = SaveFormat pres.save(dataDir + "TextBox.pptx", save_format.Pptx) print "Created TextBox, please check the output file."
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithTables/CreateTable/' pres = 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 = FillType color = Color # Set border format for each cell row = 0 while (row < 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 # 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 = SaveFormat pres.save(dataDir + "CreateTable.pptx", save_format.Pptx) print "Created table, please check the output file."
def set_rotation_and_depth(dataDir): dataDir = Settings.dataDir + 'WorkingWithCharts/ChartProperties' pres = Presentation() # Access first slide sld = pres.getSlides().get_Item(0) # Add chart with default data charType=ChartType chart = sld.getShapes().addChart(charType.StackedColumn3D, 0, 0, 500, 500) # Getting the chart data worksheet fact = chart.getChartData().getChartDataWorkbook() # Delete default generated series and categories chart.getChartData().getSeries().clear() chart.getChartData().getCategories().clear() # Adding series chart.getChartData().getSeries().add(fact.getCell(0, 0, 1, "Series 1"), chart.getType()) chart.getChartData().getSeries().add(fact.getCell(0, 0, 2, "Series 2"), chart.getType()) # Adding categories chart.getChartData().getCategories().add(fact.getCell(0, 1, 0, "Caetegoty 1")) chart.getChartData().getCategories().add(fact.getCell(0, 2, 0, "Caetegoty 2")) chart.getChartData().getCategories().add(fact.getCell(0, 3, 0, "Caetegoty 3")) # Set Rotation3D properties chart.getRotation3D().setRightAngleAxes(True) chart.getRotation3D().setRotationX(40) chart.getRotation3D().setRotationY(270) chart.getRotation3D().setDepthPercents(150) # Take first chart series series = chart.getChartData().getSeries().get_Item(0) # Populating series data series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 1, 20)) series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 1, 50)) series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 1, 30)) # Take second chart series series = chart.getChartData().getSeries().get_Item(1) # Populating series data series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 2, 30)) series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 2, 10)) series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 2, 60)) # Saving the presentation save_format = SaveFormat pres.save(dataDir + "3Drotation.pptx", save_format.Pptx) print "Done with rotation, please check the output file."
def format_join_styles(dataDir): dataDir = Settings.dataDir + 'WorkingWithShapes/FormatLines/' # Create an instance of Presentation class pres = Presentation() # Get the first slide sld = pres.getSlides().get_Item(0) # Add three autoshapes of rectangle type shape_type = ShapeType shp1 = sld.getShapes().addAutoShape(shape_type.Rectangle, 50, 100, 150, 75) shp2 = sld.getShapes().addAutoShape(shape_type.Rectangle, 300, 100, 150, 75) shp3 = sld.getShapes().addAutoShape(shape_type.Rectangle, 50, 250, 150, 75) # Set the fill color of the rectangle shape fill_type = FillType color = Color shp1.getFillFormat().setFillType(fill_type.Solid) shp1.getFillFormat().getSolidFillColor().setColor(color.BLACK) shp2.getFillFormat().setFillType(fill_type.Solid) shp2.getFillFormat().getSolidFillColor().setColor(color.BLACK) shp3.getFillFormat().setFillType(fill_type.Solid) shp3.getFillFormat().getSolidFillColor().setColor(color.BLACK) # Set the line width shp1.getLineFormat().setWidth(15) shp2.getLineFormat().setWidth(15) shp3.getLineFormat().setWidth (15) # Set the color of the line of rectangle shp1.getLineFormat().getFillFormat().setFillType(fill_type.Solid) shp1.getLineFormat().getFillFormat().getSolidFillColor().setColor(color.BLUE) shp2.getLineFormat().getFillFormat().setFillType(fill_type.Solid) shp2.getLineFormat().getFillFormat().getSolidFillColor().setColor(color.BLUE) shp3.getLineFormat().getFillFormat().setFillType(fill_type.Solid) shp3.getLineFormat().getFillFormat().getSolidFillColor().setColor(color.BLUE) # Set the Join Style line_join_style = LineJoinStyle shp1.getLineFormat().setJoinStyle(line_join_style.Miter) shp2.getLineFormat().setJoinStyle(line_join_style.Bevel) shp3.getLineFormat().setJoinStyle(line_join_style.Round) # Add text to each rectangle shp1.getTextFrame().setText ("This is Miter Join Style") shp2.getTextFrame().setText( "This is Bevel Join Style") shp3.getTextFrame().setText ("This is Round Join Style") # Write the presentation as a PPTX file save_format = SaveFormat pres.save(dataDir + "RectShpLnJoin.pptx", save_format.Pptx) print "Formatted join styles, please check the output file."
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithCharts/ChartTrendLines' # Creating empty presentation pres =Presentation() # Creating a clustered column chart chartType=ChartType chart = pres.getSlides().get_Item(0).getShapes().addChart(chartType.ClusteredColumn, 20, 20, 500, 400) # Adding ponential trend line for chart series 1 trendlineType=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=FillType color=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 = SaveFormat pres.save(dataDir + "ChartTrendLines.pptx", save_format.Pptx) print "Done with chart trend lines, please check the output file."
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithPresentation/ConvertingToPdf/' # Instantiate a Presentation object that represents a PPTX file pres = Presentation(dataDir + "Aspose.pptx") # Saving the PPTX presentation to Pdf format save_format = SaveFormat pres.save(dataDir + "Aspose.pdf", save_format.Pdf) print "Document has been converted, please check the output file."
def convert_to_pdf_notes(dataDir): dataDir = Settings.dataDir + 'WorkingWithPresentation/ConvertingToNotes/' # Instantiate a Presentation object that represents a PPTX file pres = Presentation(dataDir + "Aspose.pptx") # Saving the presentation save_format = SaveFormat pres.save(dataDir + "Notes.pdf", save_format.pdf) print "Document has been converted, please check the output file."
def add_custom_error_bar_value(dataDir): dataDir = Settings.dataDir + "WorkingWithCharts/ErrorBars" pres = Presentation() slide = pres.getSlides().get_Item(0) # Creating a bubble chart chartType = ChartType chart = pres.getSlides().get_Item(0).getShapes().addChart(chartType.Bubble, 50, 50, 400, 300, True) # Adding custom Error bars and setting its format error_bar_value_type = ErrorBarValueType series = chart.getChartData().getSeries().get_Item(0) error_bar_x = series.getErrorBarsXFormat() error_bar_y = series.getErrorBarsYFormat() # error_bar_x.isVisible(True) # error_bar_y.isVisible(True) error_bar_x.setValueType(error_bar_value_type.Custom) error_bar_y.setValueType(error_bar_value_type.Custom) # Accessing chart series data point and setting error bars values for individual point data_source_type = DataSourceType points = series.getDataPoints() points.getDataSourceTypeForErrorBarsCustomValues().setDataSourceTypeForXPlusValues( data_source_type.DoubleLiterals ) points.getDataSourceTypeForErrorBarsCustomValues().setDataSourceTypeForXMinusValues( data_source_type.DoubleLiterals ) points.getDataSourceTypeForErrorBarsCustomValues().setDataSourceTypeForYPlusValues( data_source_type.DoubleLiterals ) points.getDataSourceTypeForErrorBarsCustomValues().setDataSourceTypeForYMinusValues( data_source_type.DoubleLiterals ) # Setting error bars for chart series points i = 0 while i < points.size(): points.get_Item(i).getErrorBarsCustomValues().getXMinus().setAsLiteralDouble(i + 1) points.get_Item(i).getErrorBarsCustomValues().getXPlus().setAsLiteralDouble(i + 1) points.get_Item(i).getErrorBarsCustomValues().getYMinus().setAsLiteralDouble(i + 1) points.get_Item(i).getErrorBarsCustomValues().getYPlus().setAsLiteralDouble(i + 1) i += 1 save_format = SaveFormat pres.save(dataDir + "ErrorBarsCustomValues.pptx", save_format.Pptx) print "Added custom error bars values for chart, please check the output file."
def convert_with_default_size(dataDir): dataDir = Settings.dataDir + 'WorkingWithPresentation/ConvertingToXps/' # Instantiate a Presentation object that represents a PPTX file pres = Presentation(dataDir + "Aspose.pptx") # Saving the presentation to XPS format save_format = SaveFormat pres.save(dataDir + "Aspose.xps", save_format.Xps) print "Document has been converted, please check the output file."
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithPresentation/OdpToPptx/' # Instantiate a Presentation object that represents a PPTX file pres = Presentation(dataDir + "Source.odp") # Saving the PPTX presentation to PPTX format save_format = SaveFormat pres.save(dataDir + "Source.pptx", save_format.Pptx) print "Document has been converted, please check the output file."
def set_gapwidth(dataDir): dataDir = Settings.dataDir + 'WorkingWithCharts/ChartProperties' pres = Presentation() # Access first slide sld = pres.getSlides().get_Item(0) # Add chart with default data charType=ChartType chart = sld.getShapes().addChart(charType.StackedColumn3D, 0, 0, 500, 500) # Getting the chart data worksheet fact = chart.getChartData().getChartDataWorkbook() # Delete default generated series and categories chart.getChartData().getSeries().clear() chart.getChartData().getCategories().clear() # Adding series chart.getChartData().getSeries().add(fact.getCell(0, 0, 1, "Series 1"), chart.getType()) chart.getChartData().getSeries().add(fact.getCell(0, 0, 2, "Series 2"), chart.getType()) # Adding categories chart.getChartData().getCategories().add(fact.getCell(0, 1, 0, "Caetegoty 1")) chart.getChartData().getCategories().add(fact.getCell(0, 2, 0, "Caetegoty 2")) chart.getChartData().getCategories().add(fact.getCell(0, 3, 0, "Caetegoty 3")) # Take first chart series series = chart.getChartData().getSeries().get_Item(0) # Populating series data series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 1, 20)) series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 1, 50)) series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 1, 30)) # Take second chart series series = chart.getChartData().getSeries().get_Item(1) # Populating series data series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 2, 30)) series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 2, 10)) series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 2, 60)) # Set GapWidth value series.getParentSeriesGroup().setGapWidth(75) # Saving the presentation save_format = SaveFormat pres.save(dataDir + "SetGapWidth.pptx", save_format.Pptx) print "Set Gapwidth property of chart series, please check the output file."
def font_properties(dataDir): dataDir = Settings.dataDir + 'WorkingWithText/TextFont/' # Create an instance of Presentation class pres = Presentation(dataDir + 'Welcome.pptx') # Get the first slide slide = pres.getSlides().get_Item(0) # Accessing the first and second placeholder in the slide and typecasting it as AutoShape tf1 = slide.getShapes().get_Item(0).getTextFrame() tf2 = slide.getShapes().get_Item(1).getTextFrame() # Accessing the first Paragraph para1 = tf1.getParagraphs().get_Item(0) para2 = tf2.getParagraphs().get_Item(0) # Accessing the first portion port1 = para1.getPortions().get_Item(0) port2 = para2.getPortions().get_Item(0) # Define fonts fd1 = FontData("Elephant") fd2 = FontData("Castellar") # Assign fonts to portion port1.getPortionFormat().setLatinFont(fd1) port2.getPortionFormat().setLatinFont(fd2) # Set font to Bold nullableBool = NullableBool port1.getPortionFormat().setFontBold(nullableBool. True) port2.getPortionFormat().setFontBold(nullableBool. True) # Set font to Italic port1.getPortionFormat().setFontItalic(nullableBool. True) port2.getPortionFormat().setFontItalic(nullableBool. True) # Set font color fillType = FillType color = Color port1.getPortionFormat().getFillFormat().setFillType(fillType.Solid) port1.getPortionFormat().getFillFormat().getSolidFillColor().setColor( color.BLUE) port2.getPortionFormat().getFillFormat().setFillType(fillType.Solid) port2.getPortionFormat().getFillFormat().getSolidFillColor().setColor( color.GREEN) # Write the presentation as a PPTX file save_format = SaveFormat pres.save(dataDir + "WelcomeFont.pptx", save_format.Pptx) print "Done with font properties, please check the output file."
def get_slide_by_index(dataDir): dataDir = Settings.dataDir + 'WorkingWithSlidesInPresentation/AccessSlides/' # Instantiate Presentation class that represents the presentation file pres = Presentation(dataDir + 'Aspose.pptx') # Accessing a slide using its slide index slide = pres.getSlides().get_Item(0) print "Slide: " print slide
def font_family_of_text(dataDir): dataDir = Settings.dataDir + 'WorkingWithText/TextFont/' # Create an instance of Presentation class pres = Presentation() # Get the first slide sld = pres.getSlides().get_Item(0) # Add an AutoShape of Rectangle type shapeType = ShapeType ashp = sld.getShapes().addAutoShape(shapeType.Rectangle, 50, 50, 200, 50) # Remove any fill style associated with the AutoShape fillType = FillType ashp.getFillFormat().setFillType(fillType.NoFill) # Access the TextFrame associated with the AutoShape tf = ashp.getTextFrame() tf.setText("Aspose TextBox") # Access the Portion associated with the TextFrame port = tf.getParagraphs().get_Item(0).getPortions().get_Item(0) # Set the Font for the Portion port.getPortionFormat().setLatinFont(FontData("Times New Roman")) # Set Bold property of the Font nullableBool = NullableBool port.getPortionFormat().setFontBold(nullableBool. True) # Set Italic property of the Font port.getPortionFormat().setFontItalic(nullableBool. True) # Set Underline property of the Font textUnderlineType = TextUnderlineType port.getPortionFormat().setFontUnderline(textUnderlineType.Single) # Set the Height of the Font port.getPortionFormat().setFontHeight(25) # Set the color of the Font color = Color port.getPortionFormat().getFillFormat().setFillType(fillType.Solid) port.getPortionFormat().getFillFormat().getSolidFillColor().setColor( color.BLUE) # Write the presentation as a PPTX file save_format = SaveFormat pres.save(dataDir + "FontFamilyOfText.pptx", save_format.Pptx) print "Done with font family for text, please check the output file."
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithPresentation/PptToPptx/' # Instantiate a Presentation object that represents a PPTX file pres = Presentation(dataDir + "Presentation1.ppt") # Saving the PPTX presentation to PPTX format save_format = SaveFormat pres.save(dataDir + "Aspose.pptx", save_format.Pptx) print "Document has been converted, please check the output file."
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithShapes/FindShape/' # Create an instance of Presentation class pres = Presentation(dataDir + 'demo.pptx') # Get the first slide slide = pres.getSlides().get_Item(0) shape = self.find_shape(slide) print "Shape: ".shape
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithShapes/FindShape/' # Create an instance of Presentation class pres = Presentation(dataDir + 'demo.pptx') # Get the first slide slide = pres.getSlides().get_Item(0) shape = self.find_shape(slide) print "Shape: " . shape
def font_properties(dataDir): dataDir = Settings.dataDir + 'WorkingWithText/TextFont/' # Create an instance of Presentation class pres = Presentation(dataDir + 'Welcome.pptx') # Get the first slide slide = pres.getSlides().get_Item(0) # Accessing the first and second placeholder in the slide and typecasting it as AutoShape tf1 = slide.getShapes().get_Item(0).getTextFrame() tf2 = slide.getShapes().get_Item(1).getTextFrame() # Accessing the first Paragraph para1 = tf1.getParagraphs().get_Item(0) para2 = tf2.getParagraphs().get_Item(0) # Accessing the first portion port1 = para1.getPortions().get_Item(0) port2 = para2.getPortions().get_Item(0) # Define fonts fd1 = FontData("Elephant") fd2 = FontData("Castellar") # Assign fonts to portion port1.getPortionFormat().setLatinFont(fd1) port2.getPortionFormat().setLatinFont(fd2) # Set font to Bold nullableBool=NullableBool port1.getPortionFormat().setFontBold(nullableBool.True) port2.getPortionFormat().setFontBold(nullableBool.True) # Set font to Italic port1.getPortionFormat().setFontItalic(nullableBool.True) port2.getPortionFormat().setFontItalic(nullableBool.True) # Set font color fillType=FillType color=Color port1.getPortionFormat().getFillFormat().setFillType(fillType.Solid) port1.getPortionFormat().getFillFormat().getSolidFillColor().setColor(color.BLUE) port2.getPortionFormat().getFillFormat().setFillType(fillType.Solid) port2.getPortionFormat().getFillFormat().getSolidFillColor().setColor(color.GREEN) # Write the presentation as a PPTX file save_format = SaveFormat pres.save(dataDir + "WelcomeFont.pptx", save_format.Pptx) print "Done with font properties, please check the output file."
def font_family_of_text(dataDir): dataDir = Settings.dataDir + 'WorkingWithText/TextFont/' # Create an instance of Presentation class pres = Presentation() # Get the first slide sld = pres.getSlides().get_Item(0) # Add an AutoShape of Rectangle type shapeType=ShapeType ashp = sld.getShapes().addAutoShape(shapeType.Rectangle, 50, 50, 200, 50) # Remove any fill style associated with the AutoShape fillType=FillType ashp.getFillFormat().setFillType(fillType.NoFill) # Access the TextFrame associated with the AutoShape tf = ashp.getTextFrame() tf.setText("Aspose TextBox") # Access the Portion associated with the TextFrame port = tf.getParagraphs().get_Item(0).getPortions().get_Item(0) # Set the Font for the Portion port.getPortionFormat().setLatinFont(FontData("Times New Roman")) # Set Bold property of the Font nullableBool=NullableBool port.getPortionFormat().setFontBold(nullableBool.True) # Set Italic property of the Font port.getPortionFormat().setFontItalic(nullableBool.True) # Set Underline property of the Font textUnderlineType=TextUnderlineType port.getPortionFormat().setFontUnderline(textUnderlineType.Single) # Set the Height of the Font port.getPortionFormat().setFontHeight(25) # Set the color of the Font color=Color port.getPortionFormat().getFillFormat().setFillType(fillType.Solid) port.getPortionFormat().getFillFormat().getSolidFillColor().setColor(color.BLUE) # Write the presentation as a PPTX file save_format = SaveFormat pres.save(dataDir + "FontFamilyOfText.pptx", save_format.Pptx) print "Done with font family for text, please check the output file."
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithSlidesInPresentation/Hyperlinks/' # Instantiate Presentation class that represents the presentation file pres = Presentation(dataDir + 'demo.pptx') # Removing the hyperlinks from presentation pres.getHyperlinkQueries().removeAllHyperlinks() # Saving the presentation save_format = SaveFormat pres.save(dataDir + "Hyperlinks.pptx", save_format.Pptx) print "Removed hyperlinks successfully, please check the output file."
def remove_slide_by_id(dataDir): dataDir = Settings.dataDir + 'WorkingWithSlidesInPresentation/RemoveSlides/' # Instantiate Presentation class that represents the presentation file pres = Presentation(dataDir + 'Aspose.pptx') # Removing a slide using its slide index pres.getSlides().removeAt(1) # Saving the presentation file save_format = SaveFormat pres.save(dataDir + "Modified.pptx", save_format.Pptx) print "Removed slide by ID, please check the output file."
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithTables/AlignText/' pres = Presentation() # Get the first slide slide = pres.getSlides().get_Item(0) # Define columns with widths and rows with heights dbl_cols = [120, 120, 120, 120] dbl_rows = [100, 100, 100, 100] # Add table shape to slide tbl = slide.getShapes().addTable(100, 50, dbl_cols, dbl_rows) # Add text to the merged cell tbl.getRows().get_Item(0).get_Item(1).getTextFrame().setText("10") tbl.getRows().get_Item(0).get_Item(2).getTextFrame().setText("20") tbl.getRows().get_Item(0).get_Item(3).getTextFrame().setText("30") # Accessing the text frame txt_frame = tbl.getRows().get_Item(0).get_Item(0).getTextFrame() # Create the Paragraph object for text frame para = txt_frame.getParagraphs().get_Item(0) # Create Portion object for paragraph fillType = FillType() color = Color() portion = para.getPortions().get_Item(0) portion.setText("Text here") portion.getPortionFormat().getFillFormat().setFillType(fillType.Solid) portion.getPortionFormat().getFillFormat().getSolidFillColor( ).setColor(color.BLACK) # Aligning the text vertically textVerticalType = TextVerticalType() cell = tbl.getRows().get_Item(0).get_Item(0) textAnchorType = TextAnchorType() cell.setTextAnchorType(textAnchorType.Center) cell.setTextVerticalType(textVerticalType.Vertical270) # Write the presentation as a PPTX file save_format = SaveFormat() pres.save(dataDir + "AlignText.pptx", save_format.Pptx) print "Aligned Text, please check the output file."
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithText/WordArt/' # Create an instance of Presentation class pres = Presentation() # Get the first slide slide = pres.getSlides().get_Item(0) # Add an AutoShape of Rectangle type shapeType = ShapeType fillType = 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 = ColorType ef.getInnerShadowEffect().getShadowColor().setColorType( colorType.Scheme) # Set Scheme Color schemeColor = SchemeColor ef.getInnerShadowEffect().getShadowColor().setSchemeColor( schemeColor.Accent1) # Write the presentation as a PPTX file save_format = SaveFormat pres.save(dataDir + "WordArt.pptx", save_format.Pptx) print "Done with word art, please check the output file."
def get_slide_by_id(dataDir): dataDir = Settings.dataDir + 'WorkingWithSlidesInPresentation/AccessSlides/' # Instantiate Presentation class that represents the presentation file pres = Presentation(dataDir + 'Aspose.pptx') # Getting Slide ID id = pres.getSlides().get_Item(0).getSlideId() # Accessing Slide by ID slide = pres.getSlideById(id) print "Slide: " print slide
def convert_to_html(dataDir): dataDir = Settings.dataDir + 'WorkingWithPresentation/ConvertingToHtml/' # Instantiate a Presentation object that represents a PPTX file pres = Presentation(dataDir + "Aspose.pptx") html_opt = HtmlOptions() html_formatter = HtmlFormatter html_opt.setHtmlFormatter( html_formatter.createDocumentFormatter("", False)) # Saving the presentation to HTML format save_format = SaveFormat pres.save(dataDir + "Aspose.html", save_format.Html, html_opt) print "Document has been converted, please check the output file."
def set_anchor_of_text(dataDir): dataDir = Settings.dataDir + 'WorkingWithText/ManageText/' # Create an instance of Presentation class pres = Presentation() # Get the first slide slide = pres.getSlides().get_Item(0) # Add an AutoShape of Rectangle type shapeType = ShapeType ashp = slide.getShapes().addAutoShape(shapeType.Rectangle, 150, 75, 350, 350) # Add TextFrame to the Rectangle fillType = FillType ashp.addTextFrame(" ") ashp.getFillFormat().setFillType(fillType.NoFill) # Accessing the text frame txt_frame = ashp.getTextFrame() # Setting text anchoring to bottom textAnchorType = TextAnchorType txt_frame.getTextFrameFormat().setAnchoringType(textAnchorType.Bottom) # Create the Paragraph object for text frame para = txt_frame.getParagraphs().get_Item(0) # Create Portion object for paragraph color = Color portion = para.getPortions().get_Item(0) portion.setText( "A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog." ) portion.getPortionFormat().getFillFormat().setFillType(fillType.Solid) portion.getPortionFormat().getFillFormat().getSolidFillColor( ).setColor(color.BLACK) # Write the presentation as a PPTX file save_format = SaveFormat pres.save(dataDir + "AnchorText.pptx", save_format.Pptx) print "Set anchor of text, please check the output file."
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithSlidesInPresentation/ChangingPosition/' # Instantiate Presentation class that represents the presentation file pres = Presentation(dataDir + 'Aspose.pptx') # Get the slide whose position is to be changed slide = pres.getSlides().get_Item(0) # Set the position for the slide slide.setSlideNumber(2) # Saving the presentation save_format = SaveFormat pres.save(dataDir + "Aspose_Position.pptx", save_format.Pptx) print "Changes slide position, please check the output file."
def set_default_font_for_rendering(dataDir): dataDir = Settings.dataDir + 'WorkingWithText/TextFont/' # Use load options to define the default regualr and asian fonts loadFormat = LoadFormat lo = LoadOptions(loadFormat.Auto) lo.setDefaultRegularFont("Wingdings") lo.setDefaultAsianFont("Wingdings") # Create an instance of Presentation class pres = Presentation(dataDir + 'input.pptx') # Generate PDF save_format = SaveFormat pres.save(dataDir + "output.pdf", save_format.Pdf) print "Done with font family for text, please check the output file."
def convert_with_custom_size(dataDir): dataDir = Settings.dataDir + 'WorkingWithPresentation/ConvertingToXps/' # Instantiate a Presentation object that represents a PPTX file pres = Presentation(dataDir + "Aspose.pptx") # Instantiate the TiffOptions class opts = XpsOptions # Save MetaFiles as PNG opts.SaveMetafilesAsPng = True # Save the presentation to TIFF with specified image size save_format = SaveFormat pres.save(dataDir + "Aspose-Custom-Size.xps", save_format.Xps, opts) print "Document has been converted, please check the output file."
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithText/ReplaceText/' # Create an instance of Presentation class pres = 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 = SaveFormat pres.save(dataDir + "Welcome_PH.pptx", save_format.Pptx) print "Replaced text, please check the output file."
def create_thumbnail(dataDir): dataDir = Settings.dataDir + 'WorkingWithSlidesInPresentation/Thumbnail/' # Instantiate Presentation class that represents the presentation file pres = Presentation(dataDir + 'demo.pptx') # Access the first slide slide = pres.getSlides().get_Item(0) # Create a full scale image image = slide.getThumbnail() # Save the image to disk in JPEG format imageIO = ImageIO imageIO.write(image, "jpeg", File(dataDir + "ContentBG_tnail.jpg")) print "Created thumbnail, please check the output file.".PHP_EOL