Right-click menu to convert Word to PDF

Hello,


I'm looking for a script that will allow me to convert word documents (esp.) to PDF docs. I've tried to do a few of my own scripts and all the ones I can find online. However, none of them work the way I want. The most successful one ruined the formatting of the word doc.


Can anyone share any scripts that they may be using with Mac Automator with instructions?


Thanks a lot.


Best,

MacBook Pro, macOS Sierra (10.12.6)

Posted on Mar 29, 2018 12:54 AM

Reply
Question marked as Top-ranking reply

Posted on Mar 29, 2018 4:53 AM

If you do have Word installed, then you will have to obey its AppleScript dictionary for opening and exporting Word documents to PDF. There may also be some Automator actions installed by Word that handle this for you. I don't have any Microsoft Office for Mac installed so cannot confirm what is, and is not available.


If you do not have MS Word installed, then the next best conversion solution would be to use the command-line feature of the free LibreOffice Suite to batch convert Word .doc/x into PDF.


I have a Bash shell function setup that allows me to convert one or more specified Word files to PDF using LibreOffice:


to_pdf ()

{

for file in "$@";

do

if [ -s $file ]; then

/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf "${file}";

else

printf "\n%s\n\n" ">>> $file not found or zero length.";

continue;

fi;

done

}


Using the above Bash function on the Terminal command-line, the following three Word files will be converted to PDF in the same location as the unchanged original documents. This will also work for other documents that LibreOffice knows how to open. The LibreOffice application itself does not visually appear during this process.


$ to_pdf foo.doc foobar.docx this.docx

Here is an Automator Service that expects LibreOffice installation, and accepts selected Word .doc/x files in the Finder. It converts them to PDF in the original document location. You can single-click on this to slightly enlarge, or right-click and download the image which will be more visible.

User uploaded file

2 replies
Question marked as Top-ranking reply

Mar 29, 2018 4:53 AM in response to sjguad2014

If you do have Word installed, then you will have to obey its AppleScript dictionary for opening and exporting Word documents to PDF. There may also be some Automator actions installed by Word that handle this for you. I don't have any Microsoft Office for Mac installed so cannot confirm what is, and is not available.


If you do not have MS Word installed, then the next best conversion solution would be to use the command-line feature of the free LibreOffice Suite to batch convert Word .doc/x into PDF.


I have a Bash shell function setup that allows me to convert one or more specified Word files to PDF using LibreOffice:


to_pdf ()

{

for file in "$@";

do

if [ -s $file ]; then

/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf "${file}";

else

printf "\n%s\n\n" ">>> $file not found or zero length.";

continue;

fi;

done

}


Using the above Bash function on the Terminal command-line, the following three Word files will be converted to PDF in the same location as the unchanged original documents. This will also work for other documents that LibreOffice knows how to open. The LibreOffice application itself does not visually appear during this process.


$ to_pdf foo.doc foobar.docx this.docx

Here is an Automator Service that expects LibreOffice installation, and accepts selected Word .doc/x files in the Finder. It converts them to PDF in the original document location. You can single-click on this to slightly enlarge, or right-click and download the image which will be more visible.

User uploaded file

Mar 29, 2018 3:53 AM in response to sjguad2014

If you do have Word installed, then you will have to obey its AppleScript dictionary for opening and exporting Word documents to PDF. There may also be some Automator actions installed by Word that handle this for you. I don't have any Microsoft Office for Mac installed so cannot confirm what is, and is not available.


If you do not have MS Word installed, then the next best conversion solution would be to use the command-line feature of LibreOffice to batch convert Word .doc/x into PDF.


I have a Bash shell function setup that allows me to convert one or more specified Word files to PDF using LibreOffice:


to_pdf ()

{

for file in "$@";

do

if [ -s $file ]; then

/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf "${file}";

else

printf "\n%s\n\n" ">>> $file not found or zero length.";

continue;

fi;

done

}


Using the above Bash function on the Terminal command-line, the following three Word files will be converted to PDF in the same location as the unchanged original documents. This will also work for other documents that LibreOffice knows how to open. The LibreOffice application itself does not visually appear during this process.


$ to_pdf foo.doc foobar.docx this.docx

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Right-click menu to convert Word to PDF

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.