I have a plot which is generated by matplotlib then I save it as .png and then I place it on a PPT file using the pptx module. I want to add the border of the pic in my PPT file can any one please help me for the code..??
from pptx.util import Inches
from pptx import Presentation
prs = Presentation('dashboard.pptx')
left = Inches(0.5)
top = Inches(1)
slide = prs.slides.add_slide(prs.slide_masters[0].slide_layouts[2])
pic = slide.shapes.add_picture('test.png',left, top,width =None ,height =None)
prs.save('dashboard_new.pptx')
The Picture
object in python-pptx has a line
attribute that provides access to border properties:
So the code would go something like this:
from pptx.dml.color import RGBColor
line = pic.line
line.color.rgb = RGBColor(0xFF, 0x00, 0x00)
line.width = Inches(0.1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With