Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Anyone know how to convert word files (.doc) to PDF using the command line in Windows?

We were using the service of OpenOffice, but in documents that have many tables and images, it ends up ruining much formatting.

We're trying to find a program that converts without losing the formatting, not necessarily free. This conversion will be displayed in our Java application.

share|improve this question
    
hate to ask, but why cli specifically? scripting? –  Journeyman Geek Feb 23 '12 at 11:40
    
what exactly you want to know –  Xosler Feb 23 '12 at 12:12
    
Well, i can invoke printing off CLI, but it'll open windows for it, apparently –  Journeyman Geek Feb 23 '12 at 12:22
add comment

4 Answers 4

"winword.exe" "C:\My Files\doc1.doc" /mFilePrintDefault Provided you have quiet PDF printer as default.

Also try libreOffice offspring od OpenOffice.org. It is based of go-ooo which had no problems with OLE metrics in office.

share|improve this answer
    
I can do something like: winword.exe 'c :/ file.doc' '/ printer' 'c :/ arquivo_de_saida.pdf'? –  Xosler Feb 23 '12 at 11:13
    
currently use the service openoffice / LibreOffice, but the conversion spoils the original formatting of the file, and if we can not lose any formatting. Part of the files are. Docx with many tables, headers and footers, we must keep the original formatting –  Xosler Feb 23 '12 at 11:23
    
I am just wondering if "docx files" still have Word 6.0 compatibility attributes? Libre/OpenOffice parser does not have means to deal with them because "standard" from microsoft does not describe exact metrics. –  ZaB Feb 23 '12 at 16:48
add comment

We use the BCL easyPDF SDK for that purpose in our application. It provides much more control over how the conversion looks (e.g. how to handle Track Changes annotations).

share|improve this answer
    
wouldn't that mean actually having to write the application from scratch? –  Journeyman Geek Feb 23 '12 at 11:40
    
In theory, although the OP mentioned this being used as part of a custom Java app. For our use it was convenient to have the conversion happen on the commandline so I wrapped more or less the sample code provided on the website in a tiny executable. –  Kit Grose Feb 23 '12 at 12:14
add comment
up vote 1 down vote accepted

I found this site, and by testing OfficeToPDF, it is apparently working well. Example:

OfficeToPDF "c​​:\help.doc" "c:\output\help.pdf"
share|improve this answer
add comment

Download the free PDFTOOFFICE FROM http://officetopdf.codeplex.com/releases/view/118190

  :: PURPOSE: convert word_file to pdf_file 
  :: DEFINE VARS 
  set WORD_FILE="C:\var\anc\issues\BDCTBA-12\docs\BDC-ISG\BDC-ISG.docx"
  set PDF_FILE="C:\var\anc\issues\BDCTBA-12\docs\BDC-ISG\BDC-ISG.pdf"

  :: REMOVE FIRST THE FILE 
  DEL /Q "%PDF_FILE%

  :: CONVERT THE WORD FILE TO A PDF FILE
  :: REMEMBER TO CTRL + S , while writing ... 
  :: NOTE IF THE FILE IS OPENED IN WORD YOU WOULD HAVE TO USE READ ONLY COPY
  :: ACTION !!!
  "OFFICETOPDF.EXE" "%WORD_FILE%" "%PDF_FILE%"

  :: REQUIREMENTS
  :: DOWNLOAD OFFICETOPDF FROM [http://officetopdf.codeplex.com/releases/view/118190][2]

  :: OTHER GOODIES - call from cygwin 
  :: PATH=/cygdrive/c/WINDOWS/system32:$PATH
  :: cmd /c convert-BDC-ISG.docx-to-BDC-ISG.cmd
share|improve this answer
    
fyi, this project uses Word Interop. So Word is required to be installed. –  jltrem yesterday
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.