LibreOffice command line options

Discuss anything related to command line tools here.
Post Reply
Message
Author
User avatar
Cornflower
Posts: 244
Joined: Fri Aug 31, 2007 7:58 am
Location: Canada's capital

LibreOffice command line options

#1 Post by Cornflower »

Did you know that [LibreOffice](https://www.portablefreeware.com/index.php?id=2055) has command line options?

Here is my favourite usage, using --convert-to to create .pdf, .epub, .xhtml or UTF-encoded .txt and as source documents anything LibreOffice can open
I convert all my classes powerpoints or screenshots, for example, to pdf so I can then more easily manipulate them
c:\LibreOffice\LibreOfficePortable.exe --headless --convert-to pdf source.ppt

LibreOfficePortable.exe --help on the command line to get all the possible command line options.

User avatar
webfork
Posts: 10818
Joined: Wed Apr 11, 2007 8:06 pm
Location: US, Texas
Contact:

Re: LibreOffice command line options

#2 Post by webfork »

Cornflower wrote: Wed Dec 02, 2020 4:50 am Did you know that [LibreOffice](https://www.portablefreeware.com/index.php?id=2055) has command line options?
I've actually done a lot of work on this that I thought I had posted about, but I can't find anything. Either way this definitely deserves it's own thread in the CLI area so kudos. I will say that I've struggled with some of the batch operations (e.g. move all DOC files to PDF) but I'll try to add more on the topic soon.

User avatar
webfork
Posts: 10818
Joined: Wed Apr 11, 2007 8:06 pm
Location: US, Texas
Contact:

Re: LibreOffice command line options

#3 Post by webfork »

Some command-line functions ...

Use LibreOffice to setup your browser home page

So one way that I use portable LibreOffice conversion is to create a dynamic home page that opens up everytime I start my browser so that I always have important tools and topics right in front of me. I used to leverage KompoZer for this, but more recently I switched to SeaMonkey's editor and then finally (because I use it for everything else) LibreOffice. I then convert via batch file:

Code: Select all

C:\Temp\PortableApps\LibreOfficePortablePrevious\LibreOfficePortable.exe --headless --convert-to HTML --outdir .\web C:\Temp\Homepage.odt
This process converts the ODT file into HTML format, saved under the web subfolder in the temp directory. That auto-updates the existing Homepage.html file currently there. From there I just reload or restart my browser to see the latest-and-greatest homepage.


Use LibreOffice to batch convert files

One key element is the way you can use LO to convert things in batch, but it takes some doing. Note that I've had mixed results using this with the Portable install, meaning you may need to install the program. Below is a batch file created for Writer files (ODT) to PDF.

Code: Select all

set path=%path%;C:\Program Files (x86)\LibreOffice 4\program
for %%f in (*.odt) do (
    soffice.exe --headless --convert-to pdf --outdir "C:\tmp" %%f
)
Source: scroll down to the post by the user rafik: https://ask.libreoffice.org/en/question ... parameter/

Feedback on this is very welcome.

Post Reply