scanny / python-pptx

Create Open XML PowerPoint documents in Python
MIT License
2.4k stars 520 forks source link

Cannot open the pptx neither in Keynotes and Powerpoint. #875

Open 9Shuck opened 1 year ago

9Shuck commented 1 year ago

Hello, I'm just trying to get an example of a pptx to start adding things. But I cannot even open the pptx I got from my code.

This is the code, so simple. As I don't receive any extra info or errors don't know what is going bad.

        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')

        response = HttpResponse(prs, headers={
            'Content-Type': 'application/vnd.ms-powerpoint',
            'Content-Disposition': 'attachment; filename="test.pptx"',
        })

        return response

Thank you so much.

MartinPacker commented 1 year ago

What are your import statements?

9Shuck commented 1 year ago

Sorry for the delay, my imports are (have some Django imports on views file):

from pptx import Presentation
from ...views import viewsets, APIView, IsAuthenticated, action,\
    HttpResponse

I'm not getting any error 😅