Has anyone tried auto-generating PPTs with GPT?
I'm recently trying to build a tool that automatically creates presentation materials using the GPT API. The approach is to first generate the slide structure and then fill in the content for each slide. The challenge I'm facing is how to neatly insert tables or charts. If anyone has attempted something similar, could you share some tips? I'm using the python-pptx library in Python.
7 answers
I've made something similar, and I found that inserting tables or charts with python-pptx is trickier than expected. I solved it by saving charts as images using matplotlib and then inserting them into slides. It comes out clean and layout adjustments are easy.
When inserting a table, you can use python-pptx's add_table() method, but cell styling is limited. I wrote code to directly convert a pandas DataFrame into a table, and found it easier to apply font size or color uniformly. For charts, you can also create Excel charts with openpyxl and link them to pptx.
I'm still a beginner, so I have a question. How do you write prompts when generating slide structures with GPT? I'm planning a similar project, but I'm concerned that the structure comes out too generic. Would it be possible to share an example prompt?
Wow, presentation automation is such a necessary feature! I even struggle with manually creating pptx files... How about having GPT extract data in markdown format for tables or charts, and then parsing it with python-pptx to insert them? It works surprisingly well, in my experience.
To add a chart directly in python-pptx, you use the add_chart() method, but configuring data series can be complicated. I took a different approach: first saving the chart data as an Excel sheet, then referencing that Excel file in the pptx. It's clean, but creates a file dependency, which is a downside.
I was working on something similar but gave up because the column width wouldn't auto-adjust in the table... Have you tried using slide.placeholders? Inserting a table there makes the layout more flexible. For charts, matplotlib images work fine, and using SVG gives better resolution.
Oh, that's an interesting project! I started small by generating only the text for each slide using GPT, while pre-placing tables and charts in templates and just swapping out the data. It would be nice if python-pptx had a replace_text feature, but in the end, I found it easier to just copy slides directly.