emacs - exporting org documents to Word

https://www.reddit.com/r/emacs/comments/zjv1gj/org_files_to_docx/#:~:text=Org%20can%20export%20to%20ODT,docx.

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:

  1. Simple and straight-forward.

Cons:

  1. 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:

  1. No frills approach

Cons:

  1. Need libre-office
  2. The output is a little bland

ox-pandoc

https://github.com/kawabata/ox-pandoc

Haven’t used this myself


Links to this note