Recently I have adopted a workflow of using Obsidian to take notes, but my employer requires me to use Word to create documents. Since I like using Obsidian and vim keybinds, I was looking into using pandoc to generate Word from my markdown notes directly. Obsidian has a neat pandoc plugin, which can be used to export files to .docx
format directly from Obsidian.
Since my employer has a fixed format for documents, I needed a way to use the --reference-doc
pandoc argument, which pandoc can use to generate a .docx
file with a specific style as defined in the reference document.
The Obisidian pandoc plugin has the "Extra Pandoc arguments" option where this argument can be added. Like the person in this Obsidian Forum Thread, I was struggling with passing a file to this command line argument. As user "Karmanoid" explains, he, like myself, was trying to pass in an absolute path via the extra pandoc arguments field like --reference-doc C:\path\to\reference.docx
or a relative path for a file added to the Obsidian vault like --reference-doc .templates\reference.docx
ERROR: File .templates/reference.docx not found in resource path
The answer is quite simple once you look at it from the perspective of what Obsidian, an Electron based (i.e. Chromium/v8 based) local "web application", can see. In order for Obsidian to know to look at your PC's file system, you need to prepend the file:///
URI scheme, otherwise Obsidian will look in it's own local resource tree, which contains all the JavaScript, CSS, and HTML for rendering and running the application.
Using --reference-doc file:///C:/path/to/reference.docx
the export succeeds without any issues! (Note that use of forward slashes in the windows path isn't a requirement, backward slashes should work just fine too).