Command line (convert) parameter(s)

Hi all,
I've been looking into the command line parameters for LibO. Using
these, it is possible to do some interesting things, such as
converting from one format to another without having to run the LibO
gui. An example of what I'm talking about is to convert your odt file
to docx:
soffice.exe -headless -convert-to docx Document_name.odt

My problem is that I can't find this "-convert-to" parameter in any
proper documentation. The best I can find is some web post or
something that mentions it (but not discussed in detail), such as
http://muthusuba.blogspot.com/2011/03/so-called-hidden-features-of.html
and http://notes.benv.junerules.com/commandline-xlsdoc-to-pdf-converting/

On the wiki pages I found references to some of the command line
parameters for LibO (and OOo):
http://help.libreoffice.org/Common/Starting_the_Software_With_Parameters
http://wiki.services.openoffice.org/wiki/Framework/Article/Command_Line_Arguments

Most of these commands can also be seen by typing "soffice.exe -?".
But neither the wiki pages nor the command line help (see below)
mention the "-convert-to" parameter. Does anyone know where to find
more information? I just have a sneaking suspicion that there might
be other parameters that I'm not aware of (yet) that could prove
useful.

On a second point, "soffice.exe -?" is a little tricky. Instead of
listing the available command parameters to the console, it opens up a
"Help Message..." window (this is in Windows7 x64). Not all of the
text fits into this window, and I can't scroll or resize the window.
So in all fairness, it is possible that the "-convert-to" parameter is
mentioned there, I just can't see it in the window. Does anyone know
how I can get the help info to display properly?

Regards
Stephan

I found out about that parameter while reading the development mailing
list:

  http://thread.gmane.org/gmane.comp.documentfoundation.libreoffice.devel/9422/focus=9532

I've not tested it, but that thread points out there's some issue with
docx.

Nuno J. Silva wrote:

I found out about that parameter while reading the development mailing
list:

Yes, I also found out about it from reading a mailing list or
something. I also found it mentioned here:
http://lists.freedesktop.org/archives/libreoffice/2011-April/009994.html

I was hoping that someone could give a little more detail on it. Or
maybe someone knows of a more complete list of LibO command line
parameters (and switches) than those mentioned in the wiki.

Regards
Stephan

...

On a second point, "soffice.exe -?" is a little tricky. Instead of
listing the available command parameters to the console, it opens up a
"Help Message..." window (this is in Windows7 x64). Not all of the
text fits into this window, and I can't scroll or resize the window.
So in all fairness, it is possible that the "-convert-to" parameter is
mentioned there, I just can't see it in the window. Does anyone know
how I can get the help info to display properly?

Not sure about Windows, but here is the output of the '--help' command
in linux. I suspect that the same commands are also available in Windows.

/opt/libreoffice3.4/program/soffice --help
LibreOffice 3.4 340m1(Build:101)

Usage: soffice [options] [documents...]

Options:
--minimized keep startup bitmap minimized.
--invisible no startup screen, no default document and no UI.
--norestore suppress restart/restore after fatal errors.
--quickstart starts the quickstart service
--nologo don't show startup screen.
--nolockcheck don't check for remote instances using the installation
--nodefault don't start with an empty document
--headless like invisible but no userinteraction at all.
--help/-h/-? show this message and exit.
--version display the version information.
--writer create new text document.
--calc create new spreadsheet document.
--draw create new drawing.
--impress create new presentation.
--base create new database.
--math create new formula.
--global create new global document.
--web create new HTML document.
-o open documents regardless whether they are templates or not.
-n always open documents as new files (use as template).

--display <display>
      Specify X-Display to use in Unix/X11 versions.
-p <documents...>
      print the specified documents on the default printer.
--pt <printer> <documents...>
      print the specified documents on the specified printer.
--view <documents...>
      open the specified documents in viewer-(readonly-)mode.
--show <presentation>
      open the specified presentation and start it immediately
--accept=<accept-string>
      Specify an UNO connect-string to create an UNO acceptor through which
      other programs can connect to access the API
--unaccept=<accept-string>
      Close an acceptor that was created with -accept=<accept-string>
      Use -unnaccept=all to close all open acceptors
--infilter=<filter>
      Force an input filter type if possible
      Eg. -infilter="Calc Office Open XML"
--convert-to output_file_extension[:output_filter_name] [-outdir
ouput_dir] files
      Batch convert files.
      If -outdir is not specified then current working dir is used as
output_dir.
      Eg. -convert-to pdf *.doc
          -convert-to pdf:writer_pdf_Export -outdir /home/user *.doc
--print-to-file [-printer-name printer_name] [-outdir ouput_dir] files
      Batch print files to file.
      If -outdir is not specified then current working dir is used as
output_dir.
      Eg. -print-to-file *.doc
          -print-to-file -printer-name nasty_lowres_printer -outdir
/home/user *.doc

Remaining arguments will be treated as filenames or URLs of documents to
open.

Hi :slight_smile:
I think on Windows you can "pipe" commands although it's a bit different from
gnu&linux or bsd. I htink there is a way of piping output into a text-file but
i don't know how. This might work tho

soffice.exe -? | more

The | is not an L or i, on a UK keyboard it's between the left shift and the Z.
On american keyboards and laptops its around the Enter key but i keep forgetting
where. I think Windows command-line now allows you to repeat old commands by
pressing the keyboard's up-arrow.

I think the kind linux person's version of that quick-help thing is probably the
same as the Windows version.
Regards from
Tom :slight_smile:

NoOp <glgxg@sbcglobal.net> writes:

--convert-to output_file_extension[:output_filter_name] [-outdir
ouput_dir] files
      Batch convert files.
      If -outdir is not specified then current working dir is used as
output_dir.
      Eg. -convert-to pdf *.doc
          -convert-to pdf:writer_pdf_Export -outdir /home/user *.doc

This doesn't work:

Worked for me. I created a test.odf and then:
$ /opt/libreoffice3.4/program/soffice --convert-to pdf test.odt
and I now have:
$ ls test.pdf
test.pdf

Hi :slight_smile:
I think it might be the file-name "pdf" that might be wrong? Try "ls" or "dir"
to check the file-name. I suspect the correct file-name is either ".pdf" or
"pdf.pdf"
Regards from
Tom :slight_smile:

NoOp <glgxg@sbcglobal.net> writes:

--convert-to output_file_extension[:output_filter_name] [-outdir
ouput_dir] files

This doesn't work:

,----
> lee@yun:~/tmp$ libreoffice --headless --convert-to pdf test.odt
`----

... pops up a dialogue box saying "/home/lee/tmp/pdf does not exist."

[...]

I think it might be the file-name "pdf" that might be wrong? Try "ls" or "dir"
to check the file-name. I suspect the correct file-name is either ".pdf" or
"pdf.pdf"

According to the documentation NoOp quoted, the "pdf" is supposed to be
just the "extension".

Hi :slight_smile:
The error message is very specific. It says "/home/lee/tmp/pdf does not exist"
which means there is no file called "pdf" in the /home/lee/tmp folder. Maybe he
has missed the ending of the file-name. Or maybe he is looking in the wrong
folder.
Regards from
Tom :slight_smile:

Tom Davies <tomdavies04@yahoo.co.uk> writes:

The error message is very specific. It says "/home/lee/tmp/pdf does
not exist" which means there is no file called "pdf" in the
/home/lee/tmp folder. Maybe he has missed the ending of the
file-name. Or maybe he is looking in the wrong folder.

The message is even correct, only that's besides the point considering
what I was telling LO to do :slight_smile:

Hi :slight_smile:
Ahah. Ok, have you tried a single - as well as a doubled one -- ? Did that
just confuse it so that it outputs the quick help thing again? or did it just
appear to do nothing?
Regards from
Tom :slight_smile:

Tom Davies <tomdavies04@yahoo.co.uk> writes:

Ahah. Ok, have you tried a single - as well as a doubled one -- ? Did that
just confuse it so that it outputs the quick help thing again? or did it just
appear to do nothing?

Always top-posting ...

No, I haven't tried a single "-" because that won't make sense. There's
no single "-" with options that have a "-" in their names.

Well, I just tried, and it works. Still either the help text or the
option needs to be fixed, and that "--headless" doesn't do what it's
supposed to as well ...

Hi :slight_smile:

It's good to see that you did get it to work by using a single - i wasn't really
expecting it to work either but something you said in a previous post made it
sound like it was worth trying. The idea was yours, not mine! Given Nuno's
detailed response i'm not sure that now would be a good time to correct the
quick help. It's bad that it's wrong but if the coding is getting corrected to
follow the quick help guide then changing the guide might really mess things
up! A double -- is more consistent with other apps, as you also said.

Good luck and regards from
Tom :slight_smile:

NoOp wrote:

Not sure about Windows, but here is the output of the '--help' command
in linux. I suspect that the same commands are also available in Windows.

   <snip>

Thanks NoOp, that's what I was looking for. The message window I
described only lists the options up to "-infilter=<filter>" along with
its description. I suspect that the message window just truncates the
text at some arbitrary value.

Tom wrote:

I think on Windows you can "pipe" commands although it's a bit different from
gnu&linux or bsd. I htink there is a way of piping output into a text-file but
i don't know how. This might work tho

soffice.exe -? | more

The "|more" option does work when listing help for other types of
commands (such as "help |more"), but unfortunately it doesn't work in
this case. The main difference in this case is that the help text is
not echoed to the prompt (terminal), but it is rather displayed in a
message pop-up, which truncates (cuts off) the text at some point.

Nuno J. Silva wrote:

Lee, try with only one dash. (Yes, I'd not expect only a single dash for
long options, but it seems that this was, until recently, the way
LibO/OOo did it.)

Just for interest's sake, on the Win7 system I'm using (running
LibreOfficePortable 3.3.2), the help options specify single dashes,
not double dashes. Not sure if it is OS or LibO-version specific.

Regards
Stephan

Tom wrote:

I think on Windows you can "pipe" commands although it's a bit different from
gnu&linux or bsd. I htink there is a way of piping output into a text-file but
i don't know how. This might work tho

soffice.exe -? | more

The "|more" option does work when listing help for other types of
commands (such as "help |more"), but unfortunately it doesn't work in
this case. The main difference in this case is that the help text is
not echoed to the prompt (terminal), but it is rather displayed in a
message pop-up, which truncates (cuts off) the text at some point.

According to the code, only UNIX systems get the help text written to
the console. Everything else gets a dialog box.

,----[desktop/source/app/cmdlinehelp.cxx, line 154]

#ifdef UNX
        // on unix use console for output
        fprintf(stdout, "%s%s",
[...]
#else
        // rest gets a dialog box
        CmdlineHelpDialog aDlg;

`----

Nuno J. Silva wrote:

According to the code, only UNIX systems get the help text written to
the console. Everything else gets a dialog box.

,----[desktop/source/app/cmdlinehelp.cxx, line 154]
> #ifdef UNX
>         // on unix use console for output
>         fprintf(stdout, "%s%s",
> [...]
> #else
>         // rest gets a dialog box
>         CmdlineHelpDialog aDlg;
`----

Thanks Nuno. I must admit, I was suspecting Win7 of acting strangely.
Thanks for clarifying the behaviour.

Does anyone know a workaround to get the commands listed to the
console rather than the dialogue box (in Windows)? Or maybe how to
get *all* of the text from the help dialogue (not truncated)?

Regards
Stephan

Den 24-06-2011 23:31, NoOp skrev:

          -convert-to pdf:writer_pdf_Export -outdir /home/user *.doc

*Hi,
For some reason I coulnd't make the *.doc to work. Instead I managed to
create a batch file:

for %%f in (*.odt) do C:\LibO\program\soffice -invisible -convert-to pdf
-outdir Output/ "%%f"

Cheers,
Leif Lodahl

leif wrote:

*Hi,
For some reason I coulnd't make the *.doc to work. Instead I managed to
create a batch file:

Hi leif,
apparently, the * (star) character won't work properly in Windows,
according to http://muthusuba.blogspot.com/2011/03/so-called-hidden-features-of.html:
<quote>
[PS: wildcards wouldn't work correctly on windows specify the file
names (list) instead.]
<end quote>

and here http://lists.freedesktop.org/archives/libreoffice/2011-April/009991.html:
<quote>
[Eg. we cannot expand wildcards on Windows, if I am not
mistaken.]
<end quote>

If you're running Windows, this may explain why it wasn't working.

Regards
Stephan