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.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
if you have Microsoft Word installed, you can use DocTo:
batch operation is supported, all files in directory can be converted from doc to pdf:
docto -f "C:\Dir with Spaces\FilesToConvert\" -O "C:\DirToOutput" -T wdFormatPDF -OX .pdf
another option is to use the following powershell script: https://gallery.technet.microsoft.com/office/Script-to-convert-Word-f702844d
I found this site, and by testing OfficeToPDF, it is apparently working well. Example:
OfficeToPDF "c:\help.doc" "c:\output\help.pdf"
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).
I know the question is old, but the best solution to convert any kind of file to PDF is to use the PDFCreator. It is free, and has a command line EXE file you can use to convert any file to PDF. The application to read the file type has to be installed on the PC of course (you need office installed to convert an office document and Autocad to convert a CAD file). PDFCreator can run in the background and output files to a specified folder with no user interaction required. Sadly you cannot specify in the command line where to output the PDF. PDFCreator always output to the same folder specified in the settings. But knowing this, you can pick up the converted file in that folder and move/rename to wherever you want.
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] :: OTHER GOODIES - call from cygwin :: PATH=/cygdrive/c/WINDOWS/system32:$PATH :: cmd /c convert-BDC-ISG.docx-to-BDC-ISG.cmd
If you have Microsoft Word installed, you can use the
docx2pdf command line utility to batch convert docx to pdf on windows or macos. https://github.com/AlJohri/docx2pdf
pip install docx2pdf
Disclaimer: I wrote this tool after struggling to find a cross-platform solution for batch converting docx to pdf with zero formatting issues since it directly uses Microsoft Word.