docxpandocodt

Convert .odt to .docx in pandoc


I am trying to convert my libre office document into an ms word document through the following command

pandoc CS141Exam.odt -f markdown -t docx -s -o test1.docx

but I'm getting the following errors

pandoc: Cannot decode byte '\xac': Data.Text.Encoding.Fusion.streamUtf8: Invalid UTF-8 stream

What is the correct command to achieve this?


Solution

  • You've got pandoc trying to convert "from" (-f) markdown, "to" (-t) docx. But you're giving it an odt file. So it's trying to read that odt as though it were markdown and choking, because it isn't markdown. You want something closer to:

    pandoc CS141Exam.odt -f odt -t docx -s -o test1.docx
    

    but... odt isn't supported until pandoc 1.15.1, so do pandoc -v to make sure you've got a current version, too. My Ubuntu stable repo gave me 1.12.4.2 -- I had to get the latest directly from pandoc, but then this worked fine for me:

    pandoc -f odt -t docx -o example.docx example.odt 
    

    (Though I don't have MS Word so all I know is that example.docx looks fine in LibreOffice Writer)