Converter setup¶
rtflite can convert RTF documents to PDF using LibreOffice. This guide shows how to install and use LibreOffice for PDF conversion.
Install LibreOffice¶
On macOS (using Homebrew):
On Ubuntu/Debian:
On Windows (using Chocolatey):
Tip
After installation, restart your shell to ensure PATH
updates are loaded
so that rtflite can find LibreOffice.
Using the converter¶
Once LibreOffice is installed, convert RTF files to PDF in your code:
import rtflite as rtf
# Create your RTF document
doc = rtf.RTFDocument(df=df, ...)
doc.write_rtf("output.rtf")
# Convert to PDF
try:
converter = rtf.LibreOfficeConverter()
converter.convert(
input_files="output.rtf",
output_dir=".",
format="pdf",
overwrite=True
)
print("PDF created successfully!")
except FileNotFoundError:
print("LibreOffice not found. Please install it for PDF conversion.")
Custom installation paths¶
If LibreOffice is installed in a non-standard location, you can specify the path:
Supported output formats¶
Besides PDF, LibreOffice can convert RTF to:
docx
- Microsoft Word formathtml
- HTML formatodt
- OpenDocument Text format
Example:
Batch conversion¶
Convert multiple RTF files at once:
files = ["file1.rtf", "file2.rtf", "file3.rtf"]
converter = rtf.LibreOfficeConverter()
converter.convert(
input_files=files,
output_dir="pdfs/",
format="pdf",
overwrite=True
)
CI/CD integration¶
For automated workflows:
GitHub Actions¶
Docker¶
Troubleshooting¶
"Can't find LibreOffice executable" error¶
- Ensure LibreOffice is installed
- Restart your terminal/IDE
- Check if
soffice
is in your PATH: - macOS/Linux:
which soffice
- Windows:
where soffice
- If not in PATH, specify the full path when creating the converter
Version requirements¶
Minimum version requirement
rtflite requires LibreOffice version 7.1 or higher. Check your version:
Performance tips¶
Optimization suggestions
- LibreOffice starts a background process for conversions.
- For batch conversions, reuse the same converter instance.
- The first conversion may be slower as LibreOffice initializes.
- Consider using thread-based parallel processing for large batches.