{"id":13585390,"url":"https://github.com/unoconv/unoserver","last_synced_at":"2025-05-15T11:04:48.926Z","repository":{"id":38812384,"uuid":"375660809","full_name":"unoconv/unoserver","owner":"unoconv","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-15T09:52:21.000Z","size":258,"stargazers_count":557,"open_issues_count":10,"forks_count":78,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-10-15T11:51:50.584Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unoconv.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-10T10:36:44.000Z","updated_at":"2024-10-15T09:52:23.000Z","dependencies_parsed_at":"2024-06-18T20:02:35.879Z","dependency_job_id":"c0c007b3-fd91-458e-8ef1-5f4eac9d0b65","html_url":"https://github.com/unoconv/unoserver","commit_stats":{"total_commits":107,"total_committers":6,"mean_commits":"17.833333333333332","dds":0.1869158878504673,"last_synced_commit":"8e71adefb4414a9b3578e4a7ba142bdedaac3776"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unoconv%2Funoserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unoconv%2Funoserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unoconv%2Funoserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unoconv%2Funoserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unoconv","download_url":"https://codeload.github.com/unoconv/unoserver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248804773,"owners_count":21164131,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T15:04:54.891Z","updated_at":"2025-04-14T00:50:47.797Z","avatar_url":"https://github.com/unoconv.png","language":"Python","funding_links":[],"categories":["Python","\u003ca name=\"conversion\"\u003e\u003c/a\u003eConversion"],"sub_categories":[],"readme":"unoserver\n=========\n\nUsing LibreOffice as a server for converting documents.\n\nOverview\n--------\n\nUsing LibreOffice to convert documents is easy, you can use a command like this to\nconvert a file to PDF, for example::\n\n    $ libreoffice --headless --convert-to pdf ~/Documents/MyDocument.odf\n\nHowever, that will load LibreOffice into memory, convert a file and then exit LibreOffice,\nwhich means that the next time you convert a document LibreOffice needs to be loaded into\nmemory again.\n\nTo avoid that, LibreOffice has a listener mode, where it can listen for commands via a port,\nand load and convert documents without exiting and reloading the software. This lowers the\nCPU load when converting many documents with somewhere between 50% and 75%, meaning you can\nconvert somewhere between two and four times as many documents in the same time using a listener.\n\nUnoserver contains three commands to help you do this, `unoserver` which starts a listener on the\nspecified IP interface and port, and `unoconverter` which will connect to a listener and ask it\nto convert a document, as well as `unocompare` which will connect to a listener and ask it\nto compare two documents and convert the result document.\n\n\nInstallation\n------------\n\nNB! Windows and Mac support is as of yet untested.\n\nUnoserver needs to be installed by and run with the same Python installation that LibreOffice uses,\nto properly run the `unoserver` command. For client/server installations, see below.\n\nOn Unix this usually means you can just install it with::\n\n   $ sudo -H pip install unoserver\n\nIf you have multiple versions of LibreOffice installed, you need to install it for each one.\nUsually each LibreOffice install will have it's own `python` executable and you need to run\n`pip` with that executable::\n\n  $ sudo -H /full/path/to/python -m pip install unoserver\n\nTo find all Python installations that have the relevant LibreOffice libraries installed,\nyou can run a script called `find_uno.py`::\n\n  wget -O find_uno.py https://gist.githubusercontent.com/regebro/036da022dc7d5241a0ee97efdf1458eb/raw/find_uno.py\n  python3 find_uno.py\n\nThis should give an output similar to this::\n\n  Trying python found at /usr/bin/python3... Success!\n  Trying python found at /opt/libreoffice7.1/program/python... Success!\n  Found 2 Pythons with Libreoffice libraries:\n  /usr/bin/python3\n  /opt/libreoffice7.1/program/python\n\nThe `/usr/bin/python3` binary will be the system Python used for versions of\nLibreoffice installed by the system package manager. The Pythons installed\nunder `/opt/` will be Python versions that come with official LibreOffice\ndistributions.\n\nTo install on such distributions, do the following::\n\n  $ wget https://bootstrap.pypa.io/get-pip.py\n  $ sudo /path/to/python get-pip.py\n  $ sudo /path/to/python -m pip install unoserver\n\nYou can also install it in a virtualenv, if you are using the system Python\nfor that virtualenv, and specify the ``--system-site-packages`` parameter::\n\n  $ virtualenv --python=/usr/bin/python3 --system-site-packages virtenv\n  $ virtenv/bin/pip install unoserver\n\nWindows and Mac installs aren't officially supported yet, but on Windows the\npaths to the LibreOffice Python executable are usually in locations such as\n`C:\\\\Program Files (x86)\\\\LibreOffice\\\\python.exe`. On Mac it can be for\nexample `/Applications/LibreOffice.app/Contents/python` or\n`/Applications/LibreOffice.app/Contents/Resources/python`.\n\n\nUsage\n-----\n\nInstalling unoserver installs three scripts, `unoserver`, `unoconverter` and `unocompare`.\nThe server can also be run as a module with `python3 -m unoserver.server`, with the same\narguments as the main script, which can be useful as it must be run with the LibreOffice\nprovided Python.\n\n\nUnoserver\n~~~~~~~~~\n\n.. code::\n\n  unoserver [-h] [-v] [--interface INTERFACE] [--uno-interface UNO_INTERFACE] [--port PORT] [--uno-port UNO_PORT]\n            [--daemon] [--executable EXECUTABLE] [--user-installation USER_INSTALLATION]\n            [--libreoffice-pid-file LIBREOFFICE_PID_FILE] [--conversion-timeout CONVERSION_TIMEOUT]\n            [--stop-after STOP_AFTER] [--verbose] [--quiet]\n\n* `-v, --version`: Display version and exit.\n* `--interface`: The interface used by the XMLRPC server, defaults to \"127.0.0.1\"\n* `--port`: The port used by the XMLRPC server, defaults to \"2003\"\n* `--uno-interface`: The interface used by the LibreOffice server, defaults to \"127.0.0.1\"\n* `--uno-port`: The port used by the LibreOffice server, defaults to \"2002\"\n* `--daemon`: Deamonize the server\n* `--executable`: The path to the LibreOffice executable\n* `--user-installation`: The path to the LibreOffice user profile, defaults to a dynamically created temporary directory\n* `--libreoffice-pid-file`: If set, unoserver will write the Libreoffice PID to this file.\n  If started in daemon mode, the file will not be deleted when unoserver exits.\n* `--conversion-timeout`: Terminate Libreoffice and exit if a conversion does not complete in the given time (in seconds).\n* `--stop-after`: Terminate Libreoffice and exit after the given number of requests.\n* `--verbose`: Add debug information as output\n* `--quiet`: Only output errors and warnings\n\n\nUnoconvert\n~~~~~~~~~~\n\n.. code::\n\n  unoconvert [-h] [-v] [--convert-to CONVERT_TO] [--input-filter INPUT_FILTER] [--output-filter OUTPUT_FILTER]\n             [--filter-options FILTER_OPTIONS] [--update-index] [--dont-update-index] [--host HOST] [--port PORT]\n             [--host-location {auto,remote,local}] infile outfile\n\n* `infile`: The path to the file to be converted (use - for stdin)\n* `outfile`: The path to the converted file (use - for stdout)\n* `--convert-to`: The file type/extension of the output file (ex pdf). Required when using stdout\n* `--input-filter`: The LibreOffice input filter to use (ex 'writer8'), if autodetect fails\n* `--output-filter`: The export filter to use when converting. It is selected automatically if not specified.\n* `--filter`: Deprecated alias for `--output-filter`\n* `--filter-option`: Pass an option for the export filter, in name=value format, or for positional parameters, a comma separated list. Use true/false for boolean values. Can be repeated for multiple options.\n* `--filter-options`: Deprecated alias for `--filter-option`.\n* `--host`: The host used by the server, defaults to \"127.0.0.1\"\n* `--port`: The port used by the server, defaults to \"2003\"\n* `--host-location`: The host location determines the handling of files. If you run the client on the\n  same machine as the server, it can be set to local, and the files are sent as paths. If they are\n  different machines, it is remote and the files are sent as binary data. Default is auto, and it will\n  send the file as a path if the host is 127.0.0.1 or localhost, and binary data for other hosts.\n* `-v, --version`: Display version and exit.\n\nExample for setting PNG width/height::\n\n  unoconvert infile.odt outfile.png --filter-options PixelWidth=640 --filter-options PixelHeight=480\n\nExample for setting CSV output options::\n\n  unoconvert infile.xlsx outfile.csv --filter-options \"59,34,76,1\"\n\nExample for HTML export with embedded images::\n\n  unoconvert infile.odt outfile.html --filter-options EmbedImages\n\n\nUnocompare\n~~~~~~~~~~\n\n.. code::\n\n  unocompare [-h] [-v] [--file-type FILE_TYPE] [--host HOST] [--port PORT] [--host-location {auto,remote,local}]\n             oldfile newfile outfile\n\n* `oldfile`: The path to the older file to be compared with the original one (use - for stdin)\n* `newfile`: The path to the newer file to be compared with the modified one (use - for stdin)\n* `outfile`: The path to the result of the comparison and converted file (use - for stdout)\n* `--file-type`: The file type/extension of the result output file (ex pdf). Required when using stdout\n* `--host`: The host used by the server, defaults to \"127.0.0.1\"\n* `--port`: The port used by the server, defaults to \"2003\"\n* `--host-location`: The host location determines the handling of files. If you run the client on the\n  same machine as the server, it can be set to local, and the files are sent as paths. If they are\n  different machines, it is remote and the files are sent as binary data. Default is auto, and it will\n  send the file as a path if the host is 127.0.0.1 or localhost, and binary data for other hosts.\n* `-v, --version`: Display version and exit.\n\n\nClient/Server installations\n---------------------------\n\nIf you are installing Unoserver on a dedicated machine (virtual or not) to do the conversions and\nare running the commands from a different machine, or if you want to call the convert/compare commands\nfrom Python directly, the clients do not need access to Libreoffice. You can therefore follow the\ninstructions above to make Unoserver have access to the LibreOffice library, but on the client\nside you can simply install Unoserver as any other Python library, with `python -m pip install unoserver`\nusing the Python you want to use as the client executable.\n\nPlease note that there is no security on either ports used, and as a result Unoserver is vulnerable\nto DDOS attacks, and possibly worse. The ports used **must not** be accessible to anything outside the\nserver stack being used.\n\nUnoserver is designed to be started by some service management software, such as Supervisor or similar,\nthat will restart the service should it crash. Unoserver does not try to restart LibreOffice if it\ncrashes, but should instead also stop in that sitution. The ``--conversion-timeout`` argument will\nteminate LibreOffice if it takes to long to convert a document, and that termination will also result\nin Unoserver quitting. Because of this service monitoring software should be set up to restart\nUnoserver when it exits.\n\n\nDevelopment and Testing\n-----------------------\n\n1. Clone the repo from `https://github.com/unoconv/unoserver`.\n\n2. Setup a virtualenv::\n\n    $ virtualenv --system-site-packages ve\n    $ ve/bin/pip install -e .[devenv]\n\n3. Run tests::\n\n    $ ve/bin/pytest tests\n\n4. Run `flake8` linting:\n\n    $ ve/bin/flake8 src tests\n\n\nComparison with `unoconv`\n-------------------------\n\nUnoserver started as a rewrite, and hopefully a replacement to `unoconv`, a module with support\nfor using LibreOffice as a listener to convert documents.\n\nDifferences for the user\n~~~~~~~~~~~~~~~~~~~~~~~~\n\n* Easier install for system versions of LibreOffice. On Linux, the packaged versions of LibreOffice\n  typically uses the system Python, making it easy to install `unoserver` with a simple\n  `sudo pip install unoserver` command.\n\n* Separate commands for server and client. The client no longer tries to start a listener and then\n  close it after conversion if it can't find a listener. Instead the new `unoconverter` client\n  requires the `unoserver` to be started. This makes it less practical for one-off converts,\n  but as mentioned that can easily be done with LibreOffice itself.\n\n* The `unoserver` listener does not prevent you from using LibreOffice as a normal user, while the\n  `unoconv` listener would block you from starting LibreOffice to open a document normally.\n\n* You should be able to on a multi-core machine run several `unoservers` with different ports.\n  There is however no support for any form of load balancing in `unoserver`, you would have to\n  implement that yourself in your usage of `unoconverter`. For performant multi-core scaling, it\n  is necessary to specify unique values for each `unoserver`'s `--port` and `--uno-port` options.\n\n* Only LibreOffice is officially supported. Other variations are untested.\n\n\nDifferences for the maintainer\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n* It's a complete and clean rewrite, supporting only Python 3, with easier to understand and\n  therefore easier to maintain code, hopefully meaning more people can contribute.\n\n* It doesn't rely on internal mappings of file types and export filters, but asks LibreOffice\n  for this information, which will increase compatibility with different LibreOffice versions,\n  and also lowers maintenance.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funoconv%2Funoserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funoconv%2Funoserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funoconv%2Funoserver/lists"}