In this article, we cover how to convert doc or docx to pdf in Ubuntu through lowriter command-line utility. doc or docx are file name extensions, primarily used for Microsoft Word documents. Though, there are other applications which can read/write such files. On the other hand, we have pdf - another file name extension. PDF stands for portable document format, created by Adobe.
Both these file formats are widely used. In Ubuntu, we have LibreOffice Writer or AbiWord for word processing. Whereas, for PDFs we have Atril, Evince or MuPDF. There are numerous other applications which can handle both these file formats, we have covered a few here.
The methods which we cover here have one thing in common - LibreOffice Writer. So, if you don't have that installed then install it first.
Note: Following operations require superuser privileges. In case you don't have one then, we advise you to contact your System Administrator for assistance.
Install LibreOffice Writer in Ubuntu
The package is available through standard Ubuntu repository. Therefore, update the repository to ensure we get to have the latest version of the package -
sudo apt update
And, to install LibreOffice Writer -
sudo apt install libreoffice-writer
Convert doc or docx to pdf in Ubuntu through lowriter
The package LibreOffice Writer gives us command-line utility - lowriter. Use the following syntax to convert doc or docx to pdf -
lowriter --convert-to pdf --outdir [output-directory] input-doc-or-docx-file
For instance, if we want to convert test.docx to test.pdf and save the resulting pdf file to directory - /home/techpiezo/Documents/ then,
lowriter --convert-to pdf --outdir /home/techpiezo/Documents/ test.docx
But, what if there are multiple of those then,
lowriter --convert-to pdf --outdir /home/techpiezo/Documents/ *.docx
This would convert all the docx files in the current directory to /home/techpiezo/Documents/
Just replace, docx with doc in above command for doc files.
Convert doc or docx to pdf in Ubuntu through LibreOffice Writer
There is another way to convert doc or docx files to pdf. And, that is through GUI application - LibreOffice Writer itself. Open the doc or docx file through LibreOffice Writer. From there we can Export the file as PDF. In Menu bar -
File --> Export As --> Export as PDF
And, follow Onscreen Instructions. But, if there are multiple files we need to convert then converting them from GUI - LibreOffice Writer would take considerable amount of time and effort. So, stick to command-line utility lowriter in such case.
In conclusion, we have covered how to convert doc or docx to pdf in Ubuntu through lowriter here.