RTF to PDF Command Line

Ah Got it!

CD /D S:\ProgramFiles\LibreOfficePortable

LibreOfficePortable.exe --headless --convert-to PDF --outdir c:\temp c:\document.rtf

Is however 'strange' that the options on a Windows computer need two
'--' (i.e. --headless), and on linux just need one '-' (i.e. -headless)

Should this not be more standardized?

As far as I remember, options for Windows command-line programs are delimited
by slash (e.g. del /f some_file).

So, either way, LO behavior is non-standard for Windows apps. But, on the
other hand, most of Windows users does not use terminal mode - those who do
perhaps have some experience with Linux shells as well.

You are right, so there are 2 options:
1) Do it the Windows-way, and make LO use the '/' for this stuff.

2) Do it the LO-way, and make sure the parameters are accepted the same
way on every implemented platform.

This works for me on linux:
/opt/libreoffice3.4/program/soffice -norestore -nofirststartwizard
-nologo -headless -pt CUPS-PDF-Printer 57343-001.rtf

That is:
<full path to soffice> -norestore -nofirststartwizard -nologo -headless
-pt <printername> <rtf document>

This also works:
$ /opt/libreoffice3.4/program/soffice --headless -convert-to pdf
57343-001.rtf

That is:
<full path to soffice> --headless -convert-to pdf <rtf document>

Note that 'headless' has two dashes and 'convert-to pdf' has one dash.

Ref is here:
<http://wiki.services.openoffice.org/wiki/Framework/Article/Command_Line_Arguments>
and this thread:
<http://listarchives.libreoffice.org/global/users/msg07301.html>
Note the -help commands:
<http://listarchives.libreoffice.org/global/users/msg07422.html>

I have it working! Thanks for all of your input. This is where OS excels!

Here is what I end ed up with. I created a batch file for this purpose. It will only do one file at a time. If you want a batch of file you can build another batch around this one to loop this batch against all files in a directory. This is a work-in-progress.

@Echo Off
set outdir=%1
set indir=%2
set file=%3
set outfmt=%4

if /I "%outdir%"=="" goto Input_Error
if /I "%indir%"=="" goto Input_Error
if /I "%file%"=="" goto Input_Error
if /I "%outfmt%"=="" goto Input_Error

Echo %outdir%
Echo %indir%
Echo %file%
Echo %outfmt%

for /F "tokens=1,2 delims=.. " %%a in ("%file%") do set file_name=%%a
for /F "tokens=1,2 delims=.. " %%a in ("%file%") do set file_ext=%%b

Echo %file_name%
Echo %file_ext%

CD /D S:\ProgramFiles\LibreOfficePortable
LibreOfficePortable.exe --headless --convert-to %outfmt% --outdir %outdir% %indir%%file%

:Check
IF EXIST %outdir%\%file_name%.%outfmt% goto End
Echo File not Ready Yet!
Sleep 15
Goto Check

:Input_Error
Echo Command Format: Convert {outdir} {indir} {filename} {outfmt}
Echo Example: Convert c:\temp c:\files document.rtf PDF

:End
Echo File Process Done!

I would like to convert an RTF document to PDF. I know LO can do this
but what I would like is the ability for LO to do it from the command
line. Is this possible? I am running LO 3.4.4 on Windows XP.

This works for me on linux:
/opt/libreoffice3.4/program/soffice -norestore -nofirststartwizard
-nologo -headless -pt CUPS-PDF-Printer 57343-001.rtf

That is:
<full path to soffice> -norestore -nofirststartwizard -nologo -headless
-pt<printername> <rtf document>

This also works:
$ /opt/libreoffice3.4/program/soffice --headless -convert-to pdf
57343-001.rtf

That is:
<full path to soffice> --headless -convert-to pdf<rtf document>

Note that 'headless' has two dashes and 'convert-to pdf' has one dash.

Ref is here:
<http://wiki.services.openoffice.org/wiki/Framework/Article/Command_Line_Arguments>
and this thread:
<http://listarchives.libreoffice.org/global/users/msg07301.html>
Note the -help commands:
<http://listarchives.libreoffice.org/global/users/msg07422.html>

...
This is a bit dated, but probably easily modified:
<http://www.oooninja.com/2008/02/batch-command-line-file-conversion-with.html>

good to know you got it...

command-line options are: (from linux)

~> soffice -help
LibreOffice 3.3 330m19(Build:6)

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.
-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.

One thing I tried was do do a convert of a DOCX file to ODT using this method and all I got in the ODT was an XML looking file. bit if I take the same file and open the DOCX in LO then save as ODT it works . Any ideas?

good to know you got it...

command-line options are: (from linux)

~> soffice -help
LibreOffice 3.3 330m19(Build:6)

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.
-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.

<full path to soffice> --headless -convert-to odt <.docx document>

Works for me.
$ /opt/libreoffice3.4/program/soffice --headless -convert-to odt
57343-001.docx
convert /home/<user>/tempdir/G/OOotest/57343-001.docx ->
/home/<user>/tempdir/G/OOotest/57343-001.odt using OpenDocument Text
Flat XML
Overwriting: /home/<user>/tempdir/G/OOotest/57343-001.odt