Reputation: 1
I've been trying to use Microsoft Word as a template with Pandoc, but I'm stuck and not sure if what I want to do is even possible. My goal is to have a Word document with a cover page where I can dynamically insert variables; for my example, let's just assume the title and Author, then have the rest of the document follow the template’s formatting.
What I Tried: Using --reference-doc (dotx/docx)
I expected Pandoc to apply the template while inserting my content. Instead, the output was completely blank—no text, just an empty file. Using --template
I tried using placeholders like $Title$ and $Author$. I kept running into UTF-8 encoding errors, even after ensuring the file was saved as UTF-8. Fixing Encoding Issues
I manually unzipped the .dotx file, checked all XML files for non-UTF-8 characters, and recompressed it.
I used PowerShell to confirm everything was properly encoded.
Despite this, Pandoc still refused to process the template and threw encoding errors UTF-8. Placeholder Formatting Issue
I also tried changing the placeholders from $Title$ to {{Title}}, but that didn’t work either. Where I’m Stuck:
If I use --reference-doc, the document is entirely blank instead of applying my formatting. If I use --template, Pandoc doesn’t seem to like the Word format, even when it’s properly encoded.
At this point, I’m unsure if Pandoc can work with Word templates how I want them to or if I’m missing something obvious. Has anyone successfully done this? Is this approach even possible with Pandoc?
Upvotes: 0
Views: 47