Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aspose-com-kb/b7424136f6a053ddbf1acd7ff8e2687f to your computer and use it in GitHub Desktop.
Save aspose-com-kb/b7424136f6a053ddbf1acd7ff8e2687f to your computer and use it in GitHub Desktop.
How to Convert SVG to Presentation using Python. For more information: https://kb.aspose.com/slides/python/how-to-convert-svg-to-presentation-using-python/
import aspose.slides as slides
filepath = "C://Words//"
#Applying the licence for Aspose.Slides to convert SVG to PPTX
svgtoSlidesLicense = slides.License()
svgtoSlidesLicense.set_license(filepath + "Conholdate.Total.Product.Family.lic")
# Make an empty presentation using the Presentation class object
with slides.Presentation() as sampleSvgPres:
#Access the first slide of the newly created presentation
slideForSvg = sampleSvgPres.slides[0]
#Load the SVG file content and insert that inside the presentation image collection
with open(filepath + "410.svg", 'r') as svgfile:
svgContent = svgfile.read().rstrip()
ppSVGImage = slides.SvgImage(svgContent)
#Add an SVG Image from the disk inside the images collection of the presentation
svgImageForSlide = sampleSvgPres.images.add_image(ppSVGImage)
#Insert a picture frame inside the shapes collection of the slide
slideForSvg.shapes.add_picture_frame(slides.ShapeType.RECTANGLE, 0, 0, 720, 540, svgImageForSlide)
#Save the presentation in PPTX format with an SVG image on the disk
slideForSvg.save(filepath + "PresentationWithSvg.pptx", slides.export.SaveFormat.PPTX)
print("Process Completed")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment