As an answer to this answer to my previous question, I wrote the following short program to try to reproduce the problem.
from pptx import Presentation
from io import BytesIO
p = Presentation()
slide = p.slides.add_slide(p.slide_layouts[0])
slide.shapes[0].text = 'asdf'
p.save('test.pptx')
out = BytesIO()
p.save(out)
out_file = open('bytes_test.pptx', 'wb', buffering=0)
out_file.write(out.read())
out_file.close()
This created two pptx files.
The first, test.pptx, contained one slide with the layout "Title Slide" and contained the string "asdf". File size was 28 KB.
Secondly, bytes_test.pptx, when it was opened in PowerPoint, showed only a large gray square that said "Click to add the first slide." File size: 0.
Works on Windows 10 with Anaconda Python 3.6.1 and python-pptx 0.6.6
Why is this happening?
source
share