How to Easily Convert a DOCX File to PDF in Mac OS X

Spread the love

If you have used Microsoft Word or received any Word documents from your friends/colleagues, you are familiar with the .docx format. It is the default file extension for any document created in Microsoft Word.

If you happen to have a number of .docx files in your Mac and would like people to only have read access to them, the best way is to convert them to PDF format so others can access them without having to install an office suite.

While there are multiple ways to convert a DOCX file to PDF, the most convenient and fastest way is described below. The reason I call it the fastest way is because it only requires right-clicking on the DOCX file.

Converting a DOCX File to PDF

You are going to create an Automator script that will handle the DOCX to PDF conversion for you.

1. Launch Automator on your Mac by clicking on Launchpad in your Dock and searching for “Automator.”

2. When Automator launches, select the “Applications” folder as the location for saving your script, and click on “New Document.”

3. On the following screen select “Service” as the document type, and click on “Choose” to create a new document that is a service.

4. You are ready to create your script. First, select “files or folders” from the “Service receives selected” drop-down menu, and then select “Finder” from the “in” drop-down menu.

5. Now, drag and drop the action labeled as “Get Specified Finder Items” from the left-panel over to the workflow that is on the right.

6. Drag and drop an action named “Run Shell Script” from the left-panel onto the right-panel that is called workflow.

7. Focus on the Run Shell Script action in the workflow, and click on the drop-down menu labeled as “Pass input” and change it to “as arguments.”

8. Here comes the main part of the procedure. You need to copy the following script and paste it into the Run Shell Script box on your workflow. This is the script that actually does the process of converting a DOCX file to PDF.

#!/bin/bash
# Jacob Salmela
# 2016-03-12
# Convert annoying DOCX into PDFs with a right-click
# Run this as an Automator Service
 
###### SCRIPT #######
for f in "$@"
do
# Get the full file PATH without the extension
filepathWithoutExtension="${f%.*}"
# Convert the DOCX to HTML, which cupsfilter knows how to turn into a PDF
textutil -convert html -output "$filepathWithoutExtension.html" "$f"
# Convert the file into a PDF
cupsfilter "$filepathWithoutExtension.html" > "$filepathWithoutExtension.pdf"
# Remove the temporary HTML file
rm "$filepathWithoutExtension.html" >/dev/null
# Uncomment the following line to remove the original file, leaving only the PDF
# rm "$f" >/dev/null
done

Note: the script above does not remove the original .docx file. You can uncomment (by removing the “#” in front of the line) the # rm "$f" >/dev/null line to have the original file removed after conversion.

9. Your script is ready, and you need to save it by clicking on the “File” menu followed by “Save…”

10. Enter a name for your service, and click on “Save.” You should enter a meaningful name. I have named it “Convert to PDF” as it is self-explanatory.

11. Now that your service is ready to do a conversion, let’s try it on a DOCX file to see if it works.

To perform a conversion, find a DOCX file, right-click on it and select “Services” followed by “Convert to PDF.”

12. Within a few seconds you should see the output PDF file in the same directory as the original file. You can now access this PDF file using any PDF reader such as Preview.

Conclusion

If you have a bunch of DOCX files on your Mac and wish to convert them to PDF but do not want to go through all the hassle, you can use the above method that only requires a right-click on the file to convert it to PDF.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time. Subscribe


Mahesh Makvana

Mahesh Makvana is a freelance tech writer who’s written thousands of posts about various tech topics on various sites. He specializes in writing about Windows, Mac, iOS, and Android tech posts. He’s been into the field for last eight years and hasn’t spent a single day without tinkering around his devices.

Comments (22)