Categories: LinuxShellUbuntu

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

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:

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

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.

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

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.

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

Recent Posts

How to Install Magento 2 on AlmaLinux

Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…

1 year ago

How to Install ISPConfig Hosting Control Panel with Apache Web Server on Ubuntu 24.04

ISPConfig is an open-source control panel that allows users to manage multiple servers from a…

1 year ago

How to Test your Email Server (SMTP) Using the Telnet Command

As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…

1 year ago

Managing Network Interfaces and Settings on Ubuntu 24.04 with nmcli

Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…

2 years ago

Using Restic Backup on Ubuntu 24.04

Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…

2 years ago

Installing phpMyAdmin on Rocky Linux 9 and Securing it with Let’s Encrypt SSL

phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…

2 years ago