emacs - exporting org documents to Word
Pandoc
For docx, if going through LibreOffice was not an option to get that docx file, use: pandoc MyFile.org -o MyExportedFile.docx
Pandoc should be able to do it.
Pros:
- Simple and straight-forward.
Cons:
- The font-size is bigger. So the number of pages is more.
(defun hm/convert-org-to-docx-with-pandoc ()
"Use Pandoc to convert .org to .docx.
Comments:
- The `-N' flag numbers the headers lines.
- Use the `--from org' flag to have this function work on files
that are in Org syntax but do not have a .org extension"
(interactive)
(message "exporting .org to .docx")
(shell-command
(concat "pandoc -N --from org " (buffer-file-name)
" -o "
(file-name-sans-extension (buffer-file-name))
(format-time-string "-%Y-%m-%d-%H%M%S") ".docx")))
Installing pandoc
USE THIS
There’s also the pandoc-bin package on AUR, which avoids the large number of Haskell dependencies that the official package tries to pull in.
paru -S pandoc-bin
DO NOT USE THIS
sudo pacman -S pandoc
This one did not work. I saw errors like this.
[explorer436@explorer436-p50-20eqs27p03 resumes]$ pandoc "Harsha Resume.org" -o MyExportedFile.docx
pandoc: error while loading shared libraries: libHSunliftio-0.2.25.1-6TQZ4UCNBtlLftWP3Dt2Ro-ghc9.2.8.so: cannot open shared object file: No such file or directory
https://github.com/jgm/pandoc/issues/8778
This isn’t a problem with pandoc; it’s a problem with the packaging, so you should report it to whoever maintains this package for arch.
Apparently they are compiling with dynamic libraries (something we don’t do with our own releases), and you are missing one of the libraries needed. That’s a packaging issue.
Alternatively you can grab a binary from our releases page, and bypass arch’s packaging.
Using LibreOffice
(setq org-odt-preferred-output-format "doc")
It basically instructions LibreOffice to convert your file. So Libreoffice needs to be available.
Org can export to ODT (which is Libreoffice/Openoffice native file format, and which is supported by MS Word).
Pros:
- No frills approach
Cons:
- Need libre-office
- The output is a little bland
ox-pandoc
https://github.com/kawabata/ox-pandoc
Haven’t used this myself