Python-pptx kütüphanesini ekliyoruz.
pip install python-pptx
Kodlar:
from pptx import Presentation from pptx.util import Inches, Pt from pptx.enum.text import PP_ALIGN prs = Presentation() blank_slide_layout = prs.slide_layouts[6] slide = prs.slides.add_slide(blank_slide_layout)
## Başlık left =Inches(0) top = Inches(0.5) width = Inches(10) height = Inches(0.75) txBox = slide.shapes.add_textbox(left, top, width, height) tf = txBox.text_frame baslik = tf.add_paragraph() print('Başlık Giriniz:') baslik.text=str(input()) baslik.alignment = PP_ALIGN.CENTER baslik.font.bold = True baslik.font.size = Pt(28) ## Metin left1 =Inches(1) top1 = Inches(1.5) width1 = Inches(8) height1 = Inches(5) txBox1 = slide.shapes.add_textbox(left1, top1, width1, height1) tf1 = txBox1.text_frame metin = tf1.add_paragraph() print('Metin Giriniz:') a=str(input()) if len(a)<1200: ##1200 sınırı metin.text=a tf1.fit_text() metin.font.size = Pt(18) print(len(metin.text)) prs.save('test.pptx')
Hello World! example(Orjinal Örnek)
from pptx import Presentation
prs = Presentation()
title_slide_layout = prs.slide_layouts[0]
slide = prs.slides.add_slide(title_slide_layout)
title = slide.shapes.title
subtitle = slide.placeholders[1]
title.text = "Hello, World!"
subtitle.text = "python-pptx was here!"
prs.save('test.pptx')
Orjinal sitesi için :
https://python-pptx.readthedocs.io/en/latest/index.html
Bir yanıt yazın