LibreOffice Writer
Overview
LibreOffice Writer skill for creating, editing, converting, and automating document workflows using the native ODT (OpenDocument Text) format.
When to Use This Skill
Use this skill when:
- Creating new documents in ODT format
- Converting documents between formats (ODT <-> DOCX, PDF, HTML, RTF, TXT)
- Automating document generation workflows
- Performing batch document operations
- Creating templates and standardized document formats
Core Capabilities
1. Document Creation
- Create new ODT documents from scratch
- Generate documents from templates
- Create mail merge documents
- Build forms with fillable fields
2. Format Conversion
- ODT to other formats: DOCX, PDF, HTML, RTF, TXT, EPUB
- Other formats to ODT: DOCX, DOC, RTF, HTML, TXT
- Batch conversion of multiple documents
3. Document Automation
- Template-based document generation
- Mail merge with data sources (CSV, spreadsheet, database)
- Batch document processing
- Automated report generation
4. Content Manipulation
- Text extraction and insertion
- Style management and application
- Table creation and manipulation
- Header/footer management
5. Integration
- Command-line automation via soffice
- Python scripting with UNO
- Integration with workflow automation tools
Workflows
Creating a New Document
Method 1: Command-Line
soffice --writer template.odt
Method 2: Python with UNO
import uno
def create_document():
local_ctx = uno.getComponentContext()
resolver = local_ctx.ServiceManager.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", local_ctx
)
ctx = resolver.resolve(
"uno:socket,host=localhost,port=8100;urp;StarOffice.ComponentContext"
)
smgr = ctx.ServiceManager
doc = smgr.createInstanceWithContext("com.sun.star.text.TextDocument", ctx)
text = doc.Text
cursor = text.createTextCursor()
text.insertString(cursor, "Hello from LibreOffice Writer!", 0)
doc.storeToURL("file:///path/to/document.odt", ())
doc.close(True)
Method 3: Using odfpy
from odf.opendocument import OpenDocumentText
from odf.text import P, H
doc = OpenDocumentText()
h1 = H(outlinelevel='1', text='Document Title')
doc.text.appendChild(h1)
doc.save("document.odt")
Converting Documents
# ODT to DOCX
soffice --headless --convert-to docx document.odt
# ODT to PDF
soffice --headless --convert-to pdf document.odt
# DOCX to ODT
soffice --headless --convert-to odt document.docx
# Batch convert
for file in *.odt; do
soffice --headless --convert-to pdf "$file"
done
Template-Based Generation
import subprocess
import tempfile
from pathlib import Path
def generate_from_template(template_path, variables, output_path):
with tempfile.TemporaryDirectory() as tmpdir:
subprocess.run(['unzip', '-q', template_path, '-d', tmpdir])
content_file = Path(tmpdir) / 'content.xml'
content = content_file.read_text()
for key, value in variables.items():
content = content.replace(f'${{{key}}}', str(value))
content_file.write_text(content)
subprocess.run(['zip', '-rq', output_path, '.'], cwd=tmpdir)
return output_path
Format Conversion Reference
Supported Input Formats
- ODT (native), DOCX, DOC, RTF, HTML, TXT, EPUB
Supported Output Formats
- ODT, DOCX, PDF, PDF/A, HTML, RTF, TXT, EPUB
Command-Line Reference
soffice --headless
soffice --headless --convert-to <format> <file>
soffice --writer # Writer
soffice --calc # Calc
soffice --impress # Impress
soffice --draw # Draw
Python Libraries
pip install odfpy # ODF manipulation
pip install ezodf # Easier ODF handling
Best Practices
- Use styles for consistency
- Create templates for recurring documents
- Ensure accessibility (heading hierarchy, alt text)
- Fill document metadata
- Store ODT source files in version control
- Test conversions thoroughly
- Embed fonts for PDF distribution
- Handle conversion failures gracefully
- Log automation operations
- Clean temporary files
Troubleshooting
Cannot open socket
killall soffice.bin
soffice --headless --accept="socket,host=localhost,port=8100;urp;"
Conversion Quality Issues
soffice --headless --convert-to pdf:writer_pdf_Export document.odt
Resources
Related Skills
- calc
- impress
- draw
- base
- docx-official
- pdf-official
- workflow-automation
1---2name: writer3description: "Document creation, format conversion (ODT/DOCX/PDF), mail merge, and automation with LibreOffice Writer."4category: document-processing5risk: safe6source: personal7date_added: "2026-02-27"8metadata:9 source: https://skillmd.com/skills/jorcan/writer10---1112# LibreOffice Writer1314## Overview1516LibreOffice Writer skill for creating, editing, converting, and automating document workflows using the native ODT (OpenDocument Text) format.1718## When to Use This Skill1920Use this skill when:21- Creating new documents in ODT format22- Converting documents between formats (ODT <-> DOCX, PDF, HTML, RTF, TXT)23- Automating document generation workflows24- Performing batch document operations25- Creating templates and standardized document formats2627## Core Capabilities2829### 1. Document Creation30- Create new ODT documents from scratch31- Generate documents from templates32- Create mail merge documents33- Build forms with fillable fields3435### 2. Format Conversion36- ODT to other formats: DOCX, PDF, HTML, RTF, TXT, EPUB37- Other formats to ODT: DOCX, DOC, RTF, HTML, TXT38- Batch conversion of multiple documents3940### 3. Document Automation41- Template-based document generation42- Mail merge with data sources (CSV, spreadsheet, database)43- Batch document processing44- Automated report generation4546### 4. Content Manipulation47- Text extraction and insertion48- Style management and application49- Table creation and manipulation50- Header/footer management5152### 5. Integration53- Command-line automation via soffice54- Python scripting with UNO55- Integration with workflow automation tools5657## Workflows5859### Creating a New Document6061#### Method 1: Command-Line62```bash63soffice --writer template.odt64```6566#### Method 2: Python with UNO67```python68import uno6970def create_document():71 local_ctx = uno.getComponentContext()72 resolver = local_ctx.ServiceManager.createInstanceWithContext(73 "com.sun.star.bridge.UnoUrlResolver", local_ctx74 )75 ctx = resolver.resolve(76 "uno:socket,host=localhost,port=8100;urp;StarOffice.ComponentContext"77 )78 smgr = ctx.ServiceManager79 doc = smgr.createInstanceWithContext("com.sun.star.text.TextDocument", ctx)80 text = doc.Text81 cursor = text.createTextCursor()82 text.insertString(cursor, "Hello from LibreOffice Writer!", 0)83 doc.storeToURL("file:///path/to/document.odt", ())84 doc.close(True)85```8687#### Method 3: Using odfpy88```python89from odf.opendocument import OpenDocumentText90from odf.text import P, H9192doc = OpenDocumentText()93h1 = H(outlinelevel='1', text='Document Title')94doc.text.appendChild(h1)95doc.save("document.odt")96```9798### Converting Documents99100```bash101# ODT to DOCX102soffice --headless --convert-to docx document.odt103104# ODT to PDF105soffice --headless --convert-to pdf document.odt106107# DOCX to ODT108soffice --headless --convert-to odt document.docx109110# Batch convert111for file in *.odt; do112 soffice --headless --convert-to pdf "$file"113done114```115116### Template-Based Generation117```python118import subprocess119import tempfile120from pathlib import Path121122def generate_from_template(template_path, variables, output_path):123 with tempfile.TemporaryDirectory() as tmpdir:124 subprocess.run(['unzip', '-q', template_path, '-d', tmpdir])125 content_file = Path(tmpdir) / 'content.xml'126 content = content_file.read_text()127 for key, value in variables.items():128 content = content.replace(f'${{{key}}}', str(value))129 content_file.write_text(content)130 subprocess.run(['zip', '-rq', output_path, '.'], cwd=tmpdir)131 return output_path132```133134## Format Conversion Reference135136### Supported Input Formats137- ODT (native), DOCX, DOC, RTF, HTML, TXT, EPUB138139### Supported Output Formats140- ODT, DOCX, PDF, PDF/A, HTML, RTF, TXT, EPUB141142## Command-Line Reference143144```bash145soffice --headless146soffice --headless --convert-to <format> <file>147soffice --writer # Writer148soffice --calc # Calc149soffice --impress # Impress150soffice --draw # Draw151```152153## Python Libraries154155```bash156pip install odfpy # ODF manipulation157pip install ezodf # Easier ODF handling158```159160## Best Practices1611621. Use styles for consistency1632. Create templates for recurring documents1643. Ensure accessibility (heading hierarchy, alt text)1654. Fill document metadata1665. Store ODT source files in version control1676. Test conversions thoroughly1687. Embed fonts for PDF distribution1698. Handle conversion failures gracefully1709. Log automation operations17110. Clean temporary files172173## Troubleshooting174175### Cannot open socket176```bash177killall soffice.bin178soffice --headless --accept="socket,host=localhost,port=8100;urp;"179```180181### Conversion Quality Issues182```bash183soffice --headless --convert-to pdf:writer_pdf_Export document.odt184```185186## Resources187188- [LibreOffice Writer Guide](https://documentation.libreoffice.org/)189- [LibreOffice SDK](https://wiki.documentfoundation.org/Documentation/DevGuide)190- [UNO API Reference](https://api.libreoffice.org/)191- [odfpy](https://pypi.org/project/odfpy/)192193## Related Skills194195- calc196- impress197- draw198- base199- docx-official200- pdf-official201- workflow-automation