How can I convert a ppt to a pdf from the command line?

75,180

Solution 1

You can use unoconv. It's available in the repositories, so you can just apt-get it: unoconv (direct install link)

Note that the info in the web page is outdated. Use man or type unoconv -h to get actual command line options. It works like this:

unoconv -f pdf presentation.odt

This command will create a presentation.pdf file.

I have only used it to batch convert ods to pdf and it works perfectly. I haven't tried it with presentations (but for a quick test now), but I expect that it will work nicely.

Note that it will not work on Lucid (10.04), because of a bug in the python-openoffice biddings. If you need to use it on Lucid, you can add this ppa to your software sources to upgrade your Openoffice version.

Solution 2

You can also use the command line of libreoffice for your purpose. This example converts all ppt-files in the current directory to pdf's:

libreoffice --headless --invisible --convert-to pdf *.ppt  

--headless
Starts in "headless mode", which allows using the application without a user interface.
This special mode can be used when the application is controlled by external clients via the API...
It implies --invisible and strictly ignores any GUI environment.

and

--invisible
Starts in invisible mode.
Neither the start-up logo nor the initial program window will be visible. LO can be controlled and documents and dialogs can be opened via the API.
When started with this parameter, it can only be quit using the taskmanager (Windows) or the kill command (UNIX based systems).

Get more information on command line options with:

man libreoffice

(Note: You have to close all running instances of LibreOffice before the command line works.)

Solution 3

The easiest way to convert .ppt files to PDF is to install unoconv through the command line:

sudo apt-get install unoconv

Then open the terminal from the drive where the ppt files are available. Now type:

unoconv -f [format] pdf  filename.ppt

That's all. Done.

Share:
75,180

Related videos on Youtube

James
Author by

James

http://twitter.com/#!/spitfireforeal

Updated on September 17, 2022

Comments

  • James
    James over 1 year

    I have a folder containing a bunch of ppts, each of which I'd like to convert to an individual pdf.

    • Marcel Stimberg
      Marcel Stimberg over 13 years
      I think you meant "a folder containing a bunch of ppts" not pdfs.
    • frabjous
      frabjous over 13 years
      Your question need better explanation. Are you trying to convert each ppt to a pdf, or all the ppts to a single pdf with different pages, or ...?
  • Marcel Stimberg
    Marcel Stimberg over 13 years
    Your example uses the wrong command (uniconv instead of unoconv)
  • James
    James over 13 years
    That gives this error: Leaking python objects bridged to UNO for reason pyuno runtime is not initialized, (the pyuno.bootstrap needs to be called before using any uno classes) Segmentation fault
  • Javier Rivera
    Javier Rivera over 13 years
    @James: Yes, I checked it on 10.04 and it gives that error. A little googling shows that there is a bug in the Openoffice version shipped with Lucid. It works on Maverick (10.10) and Hardy (8.04), the versions that I use.
  • Luis Alvarado
    Luis Alvarado about 12 years
    This solved my problem.
  • Beni Cherniavsky-Paskin
    Beni Cherniavsky-Paskin over 11 years
    --headless implies --invisible (at least on LO 3.4). Add -env:UserInstallation="file://$HOME/.libreoffice-alt" to work even with GUI instances running (credit here).
  • desgua
    desgua about 11 years
    (: - Amazing! - :)
  • YudhiWidyatama
    YudhiWidyatama over 7 years
    If someone reading this and not using ubuntu, and libreoffice still asks you for X server, you might need libreoffice-headless package installed
  • user.dz
    user.dz over 7 years
    Welcome to AskUbuntu, This is a Q&A site not a forum. Thank you sharing knowledge but no need to duplicate answers. The high voted answer already mentioned unoconv tool.
  • Saurabh
    Saurabh about 7 years
    Better to use this if you have libreoffice installed. no need to install anything extra. thanks a lot!
  • alhelal
    alhelal over 6 years
    @Tapper the explanation of the arguments used in the command makes the answer more useful and clear.
  • alhelal
    alhelal over 6 years
    @Melebius instead of "without a user interface" there is "without user a interface" in man page that made me confused. Is there any way to inform this to authority?
  • Melebius
    Melebius over 6 years
    @BandaMuhammadAlHelal According to libreoffice.org/get-help/feedback, you could create a bug report.
  • ijoseph
    ijoseph over 6 years
    FWIW, on MacOS, libreoffice binary is called soffice and is located in /Applications/LibreOffice.app/Contents/MacOS
  • Rico Picone
    Rico Picone about 6 years
    @ijoseph's tip for MacOS users works for me on 10.13.4
  • Rahul Bharadwaj
    Rahul Bharadwaj over 5 years
    For anyone wondering how to convert a folder containing any type of documents (*.txt, *.docx, *.pptx and even *.pdf etc) to PDFs : unoconv -f pdf <input-folder-path>/* --output <output-folder-path>/*
  • Anshuman Kumar
    Anshuman Kumar over 4 years
    Works on Ubuntu 18.04 too.
  • rahim.nagori
    rahim.nagori almost 4 years
    I have tried this solution on my VPS server running Cent OS 7 but getting this error : Error: source file could not be loaded. but the same command is working great if I execute this for .doc file at the same location. any help / idea
  • rahim.nagori
    rahim.nagori almost 4 years
    I have executed this command 'yum install unoconv ' after this executed the same script and it worked like a charm.
  • rahim.nagori
    rahim.nagori almost 4 years
    Thank you (y) (y) (y)
  • Esben Eickhardt
    Esben Eickhardt almost 3 years
    This seems like a more stable solution as unoconv often does not work right out of the box, and you have to fiddle with config files.
  • Paul Strobel
    Paul Strobel over 2 years
    Thanks a lot, this is a great solution!
  • Matthew T Wetzel
    Matthew T Wetzel over 2 years
    worked on ubuntu 21.10; props to libreoffice for the command line tools. This was extremely helpful