I am trying to convert a .docx received by mail to a correct pdf by using pandoc (I am using GNU/Linux).I have an error concerning characters encoding :$ pandoc file.docx -o file.pdfpandoc: Cannot decode byte '\x87': Data.Text.Encoding.decodeUtf8: Invalid UTF-8 streamI tried to identify the encoding :$ file -i file .docx file.docx: application/vnd.openxmlformats-officedocument.wordprocessingml.document; charset=binaryI am a little surprised by charset=binary (I was expecting charset=iso8859-15). However I tried to convert the .docx to utf8 anyway and it is not working : $ iconv -t utf-8 file.docxP!      $iconv: squence d'chappement non permise  la position 16I have the same error with the command line from pandoc documentation : iconv -t utf-8 file.docx | pandoc | iconv -f utf-8How can I convert this .docx to pdf with pandoc?
Convert a .docx to a .pdf with pandoc
character encoding;pandoc;microsoft word
In the documentation here, .docx is not listed as a compatible input:Pandoc is a Haskell library for converting from one markup format to  another, and a command-line tool that uses this library. It can read  markdown and (subsets of) Textile, reStructuredText, HTML, LaTeX,  MediaWiki markup, Haddock markup, OPML, and DocBook; and it can write  plain text, markdown, reStructuredText, XHTML, HTML 5, LaTeX  (including beamer slide shows), ConTeXt, RTF, OPML, DocBook,  OpenDocument, ODT, Word docx, GNU Texinfo, MediaWiki markup, EPUB (v2  or v3), FictionBook2, Textile, groff man pages, Emacs Org-Mode,  AsciiDoc, and Slidy, Slideous, DZSlides, reveal.js or S5 HTML slide  shows. It can also produce PDF output on systems where LaTeX is  installed.Try something else, like Libreoffice - which can do docx, aslong as you don't mind a few formatting errors.EDIT:The description now says that Pandoc now seems to support reading from Word DOCX (as well as DocBook and a few other formats):Pandoc is a Haskell library for converting from one markup format to  another, and a command-line tool that uses this library. It can read  markdown and (subsets of) Textile, reStructuredText, HTML, LaTeX,  MediaWiki markup, TWiki markup, Haddock markup, OPML, Emacs Org-mode,  DocBook, txt2tags, EPUB and Word docx; and it can write plain text,  markdown, reStructuredText, XHTML, HTML 5, LaTeX (including beamer  slide shows), ConTeXt, RTF, OPML, DocBook, OpenDocument, ODT, Word  docx, GNU Texinfo, MediaWiki markup, DokuWiki markup, Haddock markup,  EPUB (v2 or v3), FictionBook2, Textile, groff man pages, Emacs  Org-Mode, AsciiDoc, InDesign ICML, and Slidy, Slideous, DZSlides,  reveal.js or S5 HTML slide shows. It can also produce PDF output on  systems where LaTeX is installed.As @evilsoup suggested, this might work:cd /DIRECTORY/WITH/FILE/IN && libreoffice --headless --convert-to html 'FILE.docx' && pandoc 'FILE.html' -o 'FILE.pdf'Yes, you can use the libreoffice command with --outdir, but the html output does not always work that way...I gave this a quick test, and it seemed to work, apart from Pandoc crashing due to a gif image in the document 