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 
iconv
a source character set, using the-f
flag. For example,iconv -f ISO-8859-15 -t utf-8 file.docx
might work. No idea what the format of a .docx file is, though.iconv
directly on a.docx
file is unlikely to work.iconv
assumes that its input is a text file in some specified or inferred format. A.docx
file is actually a zip file (a compressed archive) containing (mostly) xml files. You might conceivably have some luck unzipping the.docx
file, runningiconv
on the constituent files, and then re-zipping everything back into a new.docx
, but I wouldn't bet on it working. For one thing, the xml file containing the actual content of the document specifies its encoding:encoding="UTF-8"
, for example.