PDF or Portable Document Format is mostly the first choice when it comes to printing, sharing and emailing documents, especially the larger ones. For Windows and macOS, you might be very much familiar, and also dependent on, the widely used Acrobat products for pdf creation, viewing, and editing. Unfortunately, there is no default, dedicated, pdf-creator available on your Linux systems. You can, however, use the LibreOffice products to create PDF files in Ubuntu. In this article, we will explain how you can use the Ubuntu command line, the Terminal, in order to convert and batch convert .doc and .docx files to their pdf versions.

Why the Command Line?

If you are a Terminal-savvy person, you wouldn’t want to leave the comfort of the command line and go somewhere else to do any of your daily technical activities. There is always a way to do almost all of our stuff right inside the Terminal. So, why should pdf conversion be any different! Using the Terminal makes certain tasks more efficient and, even faster. The command-line tools do not use too many resources and thus form great alternatives to the widely used graphical applications, especially if you are stuck up with older hardware.

We have run the commands and procedures mentioned in this article on a Ubuntu 18.04 LTS system.

Using the LibreOffice CLI ‘Lowriter’ for pdf conversion

LibreOffice Write is part of the LibreOffice package and is mostly available by default in most Linux distros. If your system lacks it, you can easily install it from the Ubuntu Software Manager:

Libreoffice Writer

Here, we will be making use of the CLI of the same in order to convert our documents to pdfs.

Here is how you can use the Lowriter:

Open your Ubuntu command line, the Terminal, either through the Ubuntu Application Launcher search or by using the Ctrl+Alt+T shortcut.

Please make sure that lowriter is installed on your system by running the following command:

$ lowriter --version

Lowriter Version

Convert a single file to PDF format

Use the following command syntax in order to convert a single file located in your current directory:

$ lowriter --convert-to pdf filename.doc

For .docx files,

$ lowriter --convert-to filename.docx

Here is how I converted a .docx file to pdf. located in my Downloads folder.

Convert a single docx file to PDF on Linux

As you can see above, when I listed the contents of my current folder through the ls command, I could see the newly converted pdf file listed as well.

Batch Convert files to pdf

Use the following command syntax to batch convert all .doc or .docx files to pdf, located in your current directory:

$ lowriter --convert-to pdf *.doc

For .docx files, use:

$ lowriter --convert-to pdf *.docx

Batch convert documents to PDF on Linux

This is how you can make use of the LibreOffice Writer’s CLI to convert your documents from .doc and .docx to pdfs. No extra installations or lengthy procedures are required and you have exactly what you need; a .doc/.docx to pdf conversion right through the Ubuntu command line.

How to Convert Documents to PDF Format on the Ubuntu Command Line