Multiple instances for C# automation

Is it possible to open and handle multiple LibreOffice procsses and run conversions across all of them via C#?

You’ve asked two questions.

  1. Is it possible to open and handle multiple LibO processes?

    I assume you mean concurrently, and the answer is yes. You can’t, however, run the same profile concurrently. So, to open multiple LibO processes at the same time, you need to use a not-so-well-documented command line argument:

    $ libreoffice "-env:UserInstallation=file:///tmp/LibO_Process1" &
    $ libreoffice "-env:UserInstallation=file:///tmp/LibO_Process2" &
    

    This is Unix style syntax for the terminal, but the concept is the same for Windows. Run LibO and pass it the flag telling it to use a different configuration directory for each process. When each LibO completes, you may want to remove those configuration directories.

    Note that to connect to each of these instances, you’ll need to further tell them to act as “servers” and accept incoming connections:

    $ libreoffice "-env:UserInstallation=file:///tmp/LibO_Process1" --accept="socket,port=10001;urp;" &
    $ libreoffice "-env:UserInstallation=file:///tmp/LibO_Process2" --accept="socket,port=10002;urp;" &
    [ ... ]
    

    Basically, assign each one a port through the UNO string to --accept.

  2. Does LibO have a C# API?

    I believe the answer is yes, though I have not used it myself. I just googled and the first page had a number of legitimate hits for how to do it, so I won’t go into specifics. Short answer: yes.