erdos / stencil

templating engine for DOCX and PPTX files
https://stencil.erdos.dev
Eclipse Public License 2.0
111 stars 12 forks source link

Rendered pptx file is considered corrupted by MS PowerPoint #160

Closed bgalartza closed 5 months ago

bgalartza commented 6 months ago

Describe the bug We have a pptx template file that is opened without any errors by MS PowerPoint 365. We render that file using the Clojure API (using stencil version 0.5.7). The rendered file opens in LibreOffice Impress 7.4.7, but some visual elements and styles are missing. The same file is considered corrupt when we try to open it in MS PowerPoint 365, and it has to be fixed by PowerPoint before we can do anything with it.

We have used the "Open XML SDK 2.5 Productivity Tool"[1] to validate the rendered file, and it reports several errors about missing references. Here below there is an screenshot of the tool with the error report.

image

We have tried with different template files and we always got the same kind of errors. The attached template is just a very simple template to be able to reproduce the issue. We don't even have any placeholder to be rendered.

[1] https://github.com/dotnet/Open-XML-SDK/releases/tag/v2.5

To Reproduce

(require '[stencil.api :as stencil])
(require '[clojure.java.io :as io])
(stencil/render! (stencil/prepare (io/file "document-template.pptx")) {} :output (io/file "document-rendered.pptx"))

Expected behavior The rendered file is considered valid by both MS PowerPoint 365 and the Open XML SDK 2.5 Productivity Tool.

Documents

Office versions:

Environment where template is rendered:

erdos commented 5 months ago

Hey, thanks for the detailed bug report.

I did some investiation and it looks like the ability to rendering PPTX broke with the refactors of model.clj around early 0.5.x versions. The changes there were necessary to be able to implement some more complex logics (regarding reusing numbering and custom styling between document fragments), but they made the data model rigid and unable to render PPTX files.

I will continue research on how to represent PPTX files properly. There is a bit of a complication with the circular references between slideMaster and slideLayout files.

erdos commented 5 months ago

Hello @bgalartza a fix has been implemented in #161 and I have just released version 0.5.8 with the improvements. Please test with your templates. :bow:

bgalartza commented 5 months ago

Hi erdos, We tested it with the templates we are using, and it works like a charm. We didn't find any issue. Thanks!