PDF or the Portable Document Format is mostly our 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 file creation, viewing, and editing. Unfortunately, there is no default pdf creator available on your Linux systems. You can, however, use the LibreOffice shell tools to create PDF files in Debian. In this article, we will explain how you can use the Debian 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 Debian 10 Buster 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 Debian Software Manager:

LibreOffice CLI Lowriter

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 from the command line:

Open your Debian command line, the Terminal, through the Debian Application Launcher search as follows:

Debian Terminal

The Application Launcher can be accessed using the Super/Windows key.

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

$ lowriter --version

Lowriter version check

Convert a single ODT, DOC or DOCX file to PDF

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

$ lowriter --convert-to pdf filename.odt

Or

$ lowriter --convert-to pdf filename.doc

Or

$ lowriter --convert-to filename.docx

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

DOC and DOCX file to PDF conversion

In Case of Error:

If you get the following error while trying to convert the file:

Error handling

Then, try installing the libreoffice-java-common package as follows:

$ sudo apt-get install libreoffice-java-common

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

Converted PDf file

Batch Conversion of DOC and DOCX or ODT files to pdf

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

$ lowriter --convert-to pdf *.doc

Or:

$ lowriter --convert-to pdf *.docx

Or:

$ lowriter --convert-to pdf *.odt

This is how you can make use of the LibreOffice 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 Debian command line.

Convert Documents to PDF on the Debian Command Line

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn