1. Introduction
Microsoft PowerPoint is one of the most used tools for creating and presenting slideshows. We may need to convert our PowerPoint .ppt and .pptx files to PDF for various reasons. In fact, there are several ways to achieve this, some involving the command line.
In this tutorial, we’ll discuss different methods to convert a PowerPoint file to PDF format on a Linux system. Further, we use PPT, PPTX, .ppt, and .pptx interchangeably to mean any Microsoft PowerPoint file.
2. Using LibreOffice
LibreOffice is a powerful tool to open, edit, and save office files. We can convert PowerPoint .ppt files to .pdf using LibreOffice Impress.
Let’s install LibreOffice via yum:
$ sudo yum install libreoffice-impress
Now, we can use the libreoffice command to convert a PowerPoint file:
$ libreoffice --headless --convert-to pdf my_presentation.ppt
We used the –headless option to run LibreOffice in headless mode. Thus, the user interface won’t be displayed in our conversion. Moreover, we used the –convert-to option to set the output file format, which is pdf in this case.
By default, the current working directory is the output directory. However, we can use the –outdir option to set another output path.
3. Using OpenOffice
OpenOffice is a free and open-source office suite that provides a complete set of office applications. We can also use OpenOffice for our conversion.
3.1. Download and Install OpenOffice
First, we’ll download the installation package via wget:
$ wget https://sourceforge.net/projects/openofficeorg.mirror/files/4.1.14/binaries/en-US/Apache_OpenOffice_4.1.14_Linux_x86-64_install-rpm_en-US.tar.gz
Then, we’ll extract our downloaded file using tar:
$ tar -xvf Apache_OpenOffice_4.1.14_Linux_x86-64_install-rpm_en-US.tar.gz
Here, we used the -xvf option to extract the contents of our downloaded file in the current directory and display the list of files being extracted.
Now, we navigate to the extracted directory:
$ cd en-US/DEBS/
Afterward, we can install the RPM packages via the rpm command:
$ rpm -Uvih *rpm
In this case, we used -Uvih to upgrade or install RPM packages with verbose output and a progress display. Moreover, we used *rpm to specify all RPM files in the current directory.
Finally, we’ll install one more package:
$ rpm -Uvih desktop-integration/openoffice4.1.14-redhat-menus-4.1.14-9811.noarch.rpm
Now, we have two options for our conversion.
3.2. Using the Command Line
soffice is a command-line interface for OpenOffice. soffice allows us to convert files from one format to another. Importantly, the OpenOffice service needs to be running in the background to provide the conversion functionality that we need.
First, let’s start the OpenOffice service:
$ soffice --headless --accept="socket,host=localhost,port=8100;urp;" --nofirststartwizard &
In this case, we used the –headless option to run the command without a GUI. Afterward, we used –nofirststartwizard to prevent the initialization wizard from appearing. Moreover, we used the –accept option to determine the connection setting for OpenOffice.
Here, we used several options for our connection:
- socket – communication method, TCP/IP socket
- host – connection host
- port – connection port
- urp – allow components to communicate remotely
Now, we can convert our PPT file using the soffice command:
$ soffice --convert-to pdf my_presentation.ppt
Here, we used the –convert-to option to set the output format, which is pdf in this case. Again, we can use –outdir to set an output path.
3.3. Using GUI
If we have a graphical user interface (GUI), we can convert a PPT file to PDF in graphical mode.
First, we run OpenOffice:
$ openoffice4
OpenOffice launches in GUI mode. Next, we open our presentation file.
At this point, we navigate to the File menu at the top of the screen and click Export as PDF:
As we can see, we have several options to personalize the output PDF. For example, we can set the page range to export or change the quality of our PDF file. Moreover, we can secure our PDF files by setting a password.
4. Conclusion
There are different ways to convert a PowerPoint file to PDF format from the command line on a Linux system. In this article, we looked at two popular ways are using LibreOffice or OpenOffice.
LibreOffice is available via yum, and we can use the libreoffice command to convert a PPT file to PDF. On the other hand, OpenOffice needs to be downloaded and installed manually. Moreover, we need to start the OpenOffice service in the background to convert our file.