Batch convert docx files to pdf

I have many DOCX files (of Office 365) that I need to convert to PDF. I can open each one of them and export to PDF, but I am looking for a faster solution that can run in a batch file. One option that almost works is to use LibreOffice as explained here. It works for simple docx files, but for more complex files (e.g. with images and rtl text) it messes up the layout of the file. Is there a way to do the same with MS Word?

3

2 Answers

If you have Microsoft Word installed, you can use the docx2pdf command line utility to batch convert docx to pdf on windows or macos.

Install:

pip install docx2pdf

Run:

docx2pdf myfolder/

Disclaimer: I wrote this tool after struggling to find a cross-platform solution for batch converting docx to pdf with zero formatting issues.

2

There is

this Powershell script,

the freeware File Converter,

and this readonly modified version of the doc2pdf.vbs script from winhelponline which you can also add to your Windows SendTo folder:

'Convert .doc or .docx to .pdf files via Send To menu
Set fso = CreateObject("Scripting.FileSystemObject")
For i= 0 To WScript.Arguments.Count -1 docPath = WScript.Arguments(i) docPath = fso.GetAbsolutePathName(docPath) If LCase(Right(docPath, 4)) = ".doc" Or LCase(Right(docPath, 5)) = ".docx" Then Set objWord = CreateObject("Word.Application") pdfPath = fso.GetParentFolderName(docPath) & "\" & _ fso.GetBaseName(docpath) & ".pdf" objWord.Visible = False Set objDoc = objWord.documents.open(docPath,,True) objDoc.saveas pdfPath, 17 objDoc.Close wdDoNotSaveChanges objWord.Quit End If
Next

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like