Convert PDF documents to Debian command line

PDF or portable document format is basically our first choice when it comes to printing, sharing and sending documents by e-mail, especially larger ones. For Windows and macOS, you may be very familiar with and also depend on the widely used Acrobat products for creating, viewing and editing PDF files. Unfortunately, your Linux systems do not have a pdf creator by default. However, you can use the LibreOffice shell tools to create PDFs in Debian. In this article, we will explain how you can use the Debian, Terminal command line to convert and batch convert .doc and .docx files to their pdf version.

Why command line?

If you are a terminal savvy person, you will not want to leave the command line and go somewhere else to perform any of your daily technical activities. There is always a way to do almost all of our things right in the Terminal. So why pdf conversion should be 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 excellent alternatives to widely used graphical applications, especially if you are stuck on old hardware.

We ran the commands and procedures mentioned in this article on the Debian 10 Buster system.

Using LibreOffice CLI Lowriter to Convert PDF

LibreOffice Write is part of the LibreOffice package and is mostly available by default on most Linux distributions. If this is not on your system, you can easily install it from Debian Software Manager:

Here we will use the same CLI to convert our documents to PDF files.

Here’s how you can use LOwriter from the command line:

Open the Debian command line, Terminal, by searching for the Debian launchpad as follows:

Debian Terminal

Access to the Application Launcher can be obtained using the Super / Windows key.

Verify that lowriter is installed on your system by running the following command:

$ lowriter --version

Verify Lowriter Version

Convert single ODT, DOC or DOCX file to PDF

Use the following syntax 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

This is how I converted the .docx file to pdf located in the Downloads folder.

DOC and DOCX file for PDF conversion

In case of error:

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

Error processing

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

$ sudo apt-get install libreoffice-java-common

As you can see below, when I was listing the contents of my current folder, after the pdf conversion process, with the ls command, I could also see the recently converted pdf file.

Converted PDf File

Batch convert DOC and DOCX or ODT files to PDF

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

$ lowriter --convert-to pdf *.doc

Or:

$ lowriter --convert-to pdf *.docx

Or:

$ lowriter --convert-to pdf *.odt

Here’s how you can use the CLI LibreOffice 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; Convert .doc / .docx to pdf directly through the Debian command line.

Convert PDF documents to Debian command line

Sidebar