Anyone recommend a DOC to PDF converter that can be run from the command line? It seems like an easy requirement, but I have been coming up short on free solutions.
Asked
Active
Viewed 2.5k times
12
-
I always do it with a bit of vbscript to automate Word. Word 2007/2010 can be augmented with a PDF export filter that works very well. Would that suffice? – David Heffernan Sep 26 '11 at 19:31
-
1I tried that solution. Problem is, this will be running on a server and I have been running into tons of problems doing that way. I was originally doing it in C# using the Word Interop. Thanks though. – user489041 Sep 26 '11 at 19:32
-
OK, then you should pony up and get Aspose.Words I guess. – David Heffernan Sep 26 '11 at 19:34
-
http://superuser.com/questions/393118/how-to-convert-word-doc-to-pdf-from-windows-command-line?newreg=731c209bd66443bba1de13bc0fe94eed – ch271828n May 15 '16 at 03:30
2 Answers
9
I recommend the OfficeToPDF command line application.
C:\>OfficeToPDF.exe /bookmarks /print /verbose test.docx test.pdf
Converting test.docx to test.pdf
Converting with Word converter
Completed Conversion
C:\>
I used this solution to automate the PDF generating using ANT.

daaawx
- 3,273
- 2
- 17
- 16

Ptofanelli
- 103
- 1
- 6
-
7
-
See also [this answer](https://superuser.com/a/394931/221041). In short, use `OfficeToPDF "c:\help.doc" "c:\output\help.pdf"`. Binaries here: https://github.com/cognidox/OfficeToPDF/releases. – Basj Apr 04 '18 at 13:14
4
I appreciate you are trying to do this from the command line but because you mentioned C#, the approach I use to is to first convert a doc to ps (PostScript) in C# which is relatively simple and well documented and then from the command line use Ghostscript to convert to PDF. Pls don't underestimate the tool from the basic looking website - it is amazing.

Barry Kaye
- 7,682
- 6
- 42
- 64
-
-
1
-
@David - you simply print to a PostScript printer (there is a default generic one in all flavours of Windows) - it is easy I assure you, however, I am at home (UK) and have sample code in my office. If you're interested I will post sample code into my answer tomorrow. – Barry Kaye Sep 26 '11 at 19:45
-
1@David - see OP's comments where he mentions Interop which I noted in my answer was not his chosen solution but offered in conjuntion with a command line tool which was what the OP asked for. I stand by my answer and it seemd frm OP's comments to my answer that he likes the idea. Also, the approach may have have been around for a while but 5 years out of date - no - I disagree. – Barry Kaye Sep 26 '11 at 19:57