π

UOMF: Using Template Files for Pandoc Exports to Word or LibreOffice

Show Sidebar

Silent update 2019-09-25: added to blog series "Using Org Mode Features"

Please do read my "Using Org Mode Features" (UOMF) series page for explanations on articles of this series.

The amazing @pdfkungfoo tweeted about a nice feature of Pandoc, the universal document conversion tool:

Lade das Vorlagen-Muster in Word (.dot / .docx -- egal), mache evtl. gewünschte Anpassungen an'n Stilen + speicher's als DOCX (nicht DOT) unter "my-reference.docx". Dann
Tweet by pdfkungfoo mit Hinweis auf docx-Vorlagen für pandoc.

According to the manual, the option "--reference-doc=FILE" may define a docx (Word) or odt (LibreOffice) document which is used as a format template file.

So if you do have a company template for arbitrary Word files, you could use it as a template for your export. Copy a docx file (not a dotx template) as reference.docx to either:

  1. the current folder OR
  2. a folder which is defined by --data-dir OR
  3. the system default folder for data-dir which is
    • $HOME/.pandoc on UNIX-like systems
    • C:\Documents And Settings\USERNAME\Application Data\pandoc on Windows XP you should not use any more
    • C:\Users\USERNAME\AppData\Roaming\pandoc on Windows Vista or later.

So I took a company docx, renamed it to reference.docx and copied it to C:\Users\USERNAME\AppData\Roaming\pandoc on my Windows 10. When I now export from my Emacs Org-mode to a docx file (via ox-pandoc), I get documents that follow the style of our company documents: fonts, font colors, and even the company logo.

Awesome and nifty feature.

The only thing left is that I do have to learn how to avoid Emacs opening the resulting docx file as ZIP file in a buffer instead of opening it in Word.


Related articles that link to this one:

Comment via email (persistent) or via Disqus (ephemeral) comments below: