In the next article we are going to take a look at Lowriter. We will see how we can convert multiple docx, odf, odt files to PDF using this LibreOffice CLI on our Ubuntu team.
For Windows and macOS systems, users are often very familiar with Acrobat products. These are widely used for creating, viewing, and editing .pdf files. But in Gnu / Linux, users will be able to use LibreOffice products to handle PDF files very easily in Ubuntu.
Converting multiple Microsoft Word * .docx, * .doc files or * .odf, * .odt format files to PDF at the same time, it can be tricky. Especially if it is hundreds of files and we need to batch convert them. Thanks to Lowriter we will be able to convert one or hundreds of files to PDF using the free LibreOffice office suite.
If you are a Terminal regular, you may not want to leave the comfort of the command line to perform any of your daily technical activities. We will always be able to find a way to do almost all of our things from within the Terminal. For this reason, the conversion to .pdf should be no different. Using Terminal makes certain tasks more efficient and even faster. The command line tools do not use too many resources and therefore, they are an excellent alternative to the graphical applications used by the vast majority, especially if your computer works thanks to old hardware.
In this article, we will see how we can use Ubuntu command line, to batch convert .doc and .docx files to their pdf versions. All the commands that are going to be shown next, I will use them in Ubuntu 18.04 LTS.
Using the LibreOffice CLI 'Lowriter' for PDF conversion
Nowadays, LibreOffice Writer is part of the LibreOffice package and is available by default on most Gnu / Linux distributions. If your system lacks this package for whatever reason, you will be able to easily install it from the Ubuntu software option. You just have to open it and look in it "LibreOffice Writer"
This is all that we will need to be able to use the CLI and to be able to convert our documents to PDF files.
How to use Lowriter
Now to begin, we are going to open a terminal (Ctrl + Alt + T) on our Ubuntu computer. Within it we can check that we already have Lowriter installed in our system:
lowriter --version
If the previous command shows us something equal or similar to what we can see in the screenshot, we can convert our documents to .pdf.
Convert a single file to PDF format
To carry out the conversion, we will only have follow the syntax below and use the command to convert a single .doc file, located in our current working directory:
lowriter --convert-to pdf Ejemplo1.doc
If what you want is convert a .docx file, the command to use is practically the same:
lowriter --convert-to pdf Ejemplo2.docx
As you can see from the above screenshots, when I listed the contents of my current folder via the ls command, you can also see the newly created pdf files.
Batch file conversion to pdf
If we are interested in converting a group of files to .pdf we will only have to use the following syntax. This will help us batch convert all .doc or .docx files to pdf located in our current directory:
lowriter --convert-to pdf *.doc
Si the files to convert are .docx, the command to use will be the following:
lowriter --convert-to pdf *.docx
For get help on how to use Lowriter, we can write in the terminal:
lowriter --help
What we have just seen is nothing more than a basic use of what users can do with the LibreOffice Writer CLI to convert our .doc and .docx documents to pdf. No additional installations or lengthy procedures are required and we will get exactly the .pdf files we need. For more information you can consult the page of LibreOffice official documentation.