本文整理汇总了Python中com.aspose.slides.Presentation类的典型用法代码示例。如果您正苦于以下问题:Python Presentation类的具体用法?Python Presentation怎么用?Python Presentation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Presentation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_video_frame
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."
示例2: get_properties
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()
示例3: add_fixed_error_bar_value
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."
示例4: convert_with_custom_size
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."
示例5: fill_shapes_with_solid_color
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."
示例6: fill_shapes_with_picture
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."
示例7: create_textbox_with_hyperlink
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."
示例8: __init__
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."
示例9: create_textbox
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."
示例10: create_thumbnail_custom_size
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
示例11: create_smartart_shape
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."
示例12: fill_shapes_with_pattern
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."
示例13: add_audio_frame
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."
示例14: __init__
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."
示例15: __init__
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."