Thursday, December 27, 2012
3:59 PM

CLI: Convert Microsoft Word Document to PDF Without No Additional Software

Imagine this situation, you are using Linux and want to read or print Microsoft Word document (doc or docx), you might encounter some difficulties when working with such documents. You have no Microsoft Office installed and the alternative Office Suite (LibreOffice or OpenOffice) doesn't open the document properly (lost format, font, etc). If you have an Internet access, you can solve this problem easily! Today I'd like to share the trick to convert Microsoft Word document into PDF without any additional software, just use Linux Terminal and an Internet access.

The script
Please open ".bashrc" file with your favorite text editor, and add the following code at the end of the file:
  • doc2pdf () {
  • curl -# -F inputDocument=@"$1" http://www.doc2pdf.net/convert/document.pdf > "${1%.*}.pdf"
  • }
Save the change you've made. To convert Microsoft Word document, simply open a new Terminal window and type the following command:
  • doc2pdf file_name.doc
Or if you want to convert Microsoft Office 2007 or later document, run the following command:
  • doc2pdf file_name.docx
Wait, what just happened? Simple, it sends Microsoft Word document to www.doc2pdf.net and download the converted PDF file automatically!

Demo video:


Regards :)

0 comments:

Post a Comment