This is a modular reimplementation of the unoconv tool, which converts between office document formats using LibreOffice/OpenOffice.
The original unoconv.py script has been restructured into a modular package that allows for both command-line usage and programmatic integration. The refactored version maintains all the functionality of the original script while providing a cleaner, more organized codebase.
The package is structured as follows:
unoconvert/
├── __init__.py # Package initialization and high-level API
├── cli.py # Command-line interface
├── config.py # Configuration handling
├── connection.py # LibreOffice connection management
├── converter.py # Document conversion logic
├── formats.py # Format definitions and handling
└── listener.py # Listener functionality
- Convert documents between various formats
- Start LibreOffice/OpenOffice listeners for faster conversions
- Customize document conversion with filters and templates
- Use programmatically in Python applications
- Same command-line interface as the original unoconv
pip install unoconvertThe command-line interface is similar to the original unoconv:
# Convert a document to PDF
unoconvert -f pdf document.odt
# Start a listener
unoconvert -l
# Show available formats
unoconvert --showThe modular version can be easily used in Python code:
from unoconvert import convert
# Simple conversion
convert('document.odt', 'document.pdf')
# Conversion with options
convert(
'spreadsheet.xlsx',
'spreadsheet.pdf',
format='pdf',
doctype='spreadsheet',
template='template.ott',
verbose=1
)
# Start a listener
from unoconvert import listen
listen()
# Get available formats
from unoconvert import get_formats
formats = get_formats(doctype='document')- Python 3.6+
- LibreOffice or OpenOffice
This modular version maintains all the functionality of the original unoconv script, but with several improvements:
- Modular Structure: Code is organized into logical modules for better maintainability
- Clean API: Simple, intuitive API for programmatic usage
- Modern Python: Uses modern Python features and best practices
- Better Error Handling: More consistent and informative error messages
- Easier Integration: Can be used as a library in other Python projects
See example.py for a detailed example of how to use the library programmatically to convert an Excel file to PDF.
Same as the original unoconv.