pip install python-pptx
安裝好pptx,設(shè)置標(biāo)題最大的作用是ppt里面的摘要視圖顯示摘要文字
參考:https://python-pptx.readthedocs.io/en/latest/
?文章來源:http://www.zghlxwxcb.cn/news/detail-419423.html
from pptx import Presentation from pptx.util import Cm pwidth,pheight=Cm(29.7),Cm(21)#A4大小297*210 left=top=0 prs = Presentation() # 實(shí)例化一個ppt演示文稿對象 prs.slide_width=pwidth prs.slide_height=pheight title_only_slide_layout = prs.slide_layouts[5] #實(shí)例化模板 slide = prs.slides.add_slide(title_only_slide_layout) # 向文件中添加帶標(biāo)題的頁面 slide.shapes.title.text="四大皆空副駕駛的1四大皆空副駕駛的1四大皆空副駕駛的1四大皆空副駕駛的1四大皆空副駕駛的1四大皆空副駕駛的1四大皆空副駕駛的1" slide.shapes.title.left=left slide.shapes.title.top=top slide.shapes.title.width=pwidth slide.shapes.title.height=pheight title_para = slide.shapes.title.text_frame.paragraphs[0] title_para.font.name = "微軟雅黑" title_para.font.size = Cm(1) img_path = './helloworld.jpg' # 圖片路徑 # 在頁面中插入圖片 pic = slide.shapes.add_picture(img_path,left,top,pwidth,pheight) slide = prs.slides.add_slide(title_only_slide_layout) # 再來一個頁面,對比下 slide.shapes.title.text="四大皆空副駕駛的2" title_para = slide.shapes.title.text_frame.paragraphs[0] title_para.font.name = "楷體" title_para.font.size = Cm(2) prs.save('自動生成的ppt.pptx') # 保存為文件
?文章來源地址http://www.zghlxwxcb.cn/news/detail-419423.html
到了這里,關(guān)于python操作pptx設(shè)置title字體大小插入全屏圖片A4尺寸實(shí)例一枚的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!