Converting documents to PDF on the Debian command line

s2 0

PDF or the Portable Document Format is usually our first choice when it comes to printing, sharing and sending documents, especially the larger ones. On Windows and macOS, you may be very familiar with Acrobat’s widely used products for creating, viewing, and editing PDF files. Unfortunately, there is no standard PDF creator available on your Linux systems. However, you can 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, to convert .doc and .docx files and batch convert them to their PDF versions.

Why the command line?

If you’re a terminal savvy person, you don’t want to leave the convenience of the command line and go elsewhere to do your daily tech activities. There is always a way to do almost all of our things right in 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 consume too many resources, making them great alternatives to the widely used graphical applications, especially if you are overwhelmed with older hardware.

We ran 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 suite and is mostly available by default in most Linux distributions. If your system is missing it, you can simply install it using the Debian software manager:

Here we use the same CLI to convert our documents to PDFs.

This is how you can use the LOwriter from the command line:

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

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

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

$ lowriter --version

Lowriter version checkdisplay

Convert a single ODT, DOC or DOCX file to PDF

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

$ lowriter --convert-to pdf filename.odt


$ lowriter --convert-to pdf filename.doc


$ lowriter --convert-to filename.docx

So I converted a .docx file to pdf that is in my Downloads folder.

DOC and DOCX file to PDF conversion

In the case of an error:

If you receive the following error message while trying to convert the file:

Error handling

Then try to install the libreoffice-java-common package as follows:

$ sudo apt-get install libreoffice-java-common

As you can see below, when listing the contents of my current folder after the PDF conversion process via the ls command, I was also able to see the newly converted PDF file.

Converted PDF file

Batch conversion of DOC and DOCX or ODT files to PDF

Use the following syntax to convert to pdf all of the .doc or .docx files in the batch that are in your current directory:

$ lowriter --convert-to pdf *.doc


$ lowriter --convert-to pdf *.docx


$ lowriter --convert-to pdf *.odt

So you can use the LibreOffice CLI to convert your documents from .doc and .docx to pdfs. No additional installations or lengthy procedures are required and you have exactly what you need. a .doc / .docx to PDF conversion directly from the Debian command line.

Converting documents to PDF on the Debian command line