{"id":10328,"library":"unoserver","title":"unoserver","description":"Unoserver provides a server for performing file conversions using LibreOffice or OpenOffice. It allows Python applications to convert various document types (e.g., DOCX, XLSX, ODT) to other formats (e.g., PDF) by interacting with a running LibreOffice instance via a network socket. The current version is 3.6, with development actively maintained on GitHub.","status":"active","version":"3.6","language":"en","source_language":"en","source_url":"https://github.com/unoconv/unoserver","tags":["libreoffice","file-conversion","pdf","docx","unoconv"],"install":[{"cmd":"pip install unoserver","lang":"bash","label":"Install unoserver client library"}],"dependencies":[],"imports":[{"note":"Primary class for client-side file conversions.","symbol":"UnoConverter","correct":"from unoserver.converter import UnoConverter"},{"note":"Function to programmatically start the unoserver process. While possible, starting via CLI (`unoserver`) is often preferred for deployment.","wrong":"from unoserver.server import start","symbol":"start","correct":"from unoserver import start"}],"quickstart":{"code":"import os\nfrom unoserver.converter import UnoConverter\n\n# NOTE: For this code to run, the `unoserver` command-line tool\n# must be running in a separate process, e.g., via `unoserver --log-level INFO`.\n# LibreOffice must also be installed on the server machine.\n\n# Create a dummy input file\ndummy_input_path = 'dummy_input.txt'\nwith open(dummy_input_path, 'w') as f:\n    f.write('Hello, UnoServer! This is a test document.')\n\ntry:\n    with UnoConverter() as converter:\n        # Convert the dummy text file to PDF\n        output_path = converter.convert(dummy_input_path, 'dummy_output.pdf')\n        print(f\"Successfully converted '{dummy_input_path}' to '{output_path}'\")\nexcept Exception as e:\n    print(f\"Error during conversion: {e}\")\n    print(\"Ensure `unoserver` is running and LibreOffice is installed.\")\nfinally:\n    # Clean up dummy files\n    if os.path.exists(dummy_input_path):\n        os.remove(dummy_input_path)\n    if os.path.exists('dummy_output.pdf'): # Check if conversion actually created it\n        os.remove('dummy_output.pdf')\n","lang":"python","description":"This quickstart demonstrates how to use the `UnoConverter` client to connect to a running `unoserver` instance and convert a dummy text file to PDF. It assumes that the `unoserver` command-line tool is already active in a separate process and that LibreOffice is installed on the server machine. The example creates a temporary input file and cleans up afterwards."},"warnings":[{"fix":"Rewrite conversion logic to use `unoserver.converter.UnoConverter` to connect to a running `unoserver` instance. Start `unoserver` as a separate process via the command line or `unoserver.start()`.","message":"Users migrating from the older `unoconv` Python library to `unoserver` will encounter significant breaking changes. `unoserver` fundamentally redesigns the conversion process around a client-server architecture, meaning direct function calls like `unoconv.unoconvert()` no longer exist.","severity":"breaking","affected_versions":"< 3.0 (for unoconv users)"},{"fix":"Install LibreOffice/OpenOffice on the server machine. Ensure its executable (`soffice` or similar) is accessible via the system's PATH or specify its path using the `--interface` option when starting `unoserver`.","message":"Unoserver requires LibreOffice or OpenOffice to be installed on the machine where the `unoserver` process is running. If LibreOffice is not found in the system's PATH, the server will fail to start or conversions will error out.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Change the default port using the `--port` option when starting `unoserver` (e.g., `unoserver --port 2003`). Ensure your client code connects to the correct port. Check firewall rules if connections are refused.","message":"The default port for unoserver is 2002. If another application is using this port, or if you attempt to run multiple unoserver instances on the same port, connection errors will occur. Firewalls can also block connections.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Install LibreOffice or OpenOffice. Verify it's in the system's PATH, or start `unoserver` with the `--uno-interface` option pointing to the `soffice` executable (e.g., `unoserver --uno-interface 'socket,host=127.0.0.1,port=2002;urp;StarOffice.ServiceManager;/usr/lib/libreoffice/program/soffice.bin'`).","cause":"LibreOffice/OpenOffice is not installed or its executable (`soffice`) is not found in the system's PATH on the machine running `unoserver`.","error":"FileNotFoundError: [Errno 2] No such file or directory: 'soffice'"},{"fix":"Ensure `unoserver` is running (e.g., `unoserver --log-level INFO` in a terminal). Verify the host and port match between the server startup command and the client `UnoConverter` instantiation. Check firewall settings.","cause":"The `unoserver` process is not running, is running on a different host/port, or a firewall is blocking the connection.","error":"unoserver.exceptions.UnoServerError: Could not connect to UnoServer at 127.0.0.1:2002"},{"fix":"Refactor your code to use the `unoserver.converter.UnoConverter` class. The `unoconvert` function does not exist in `unoserver`.","cause":"Attempting to use old `unoconv` library syntax with `unoserver`. The `unoserver` library has a different API based on its client-server model.","error":"AttributeError: module 'unoserver' has no attribute 'unoconvert'"}]}