[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-69a4de34-3fef-4d69-998d-798bab3437ee":3,"$fYL0K0Rvyf7bLs79fqLLgoQHN58tzr6npjRjBRGWKUgM":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"69a4de34-3fef-4d69-998d-798bab3437ee","writer","文档创建、格式转换（ODT\u002FDOCX\u002FPDF）、邮件合并以及使用LibreOffice Writer的自动化。","cat_prod_document","mod_productivity","sickn33,productivity","---\nname: writer\ndescription: \"Document creation, format conversion (ODT\u002FDOCX\u002FPDF), mail merge, and automation with LibreOffice Writer.\"\ncategory: document-processing\nrisk: safe\nsource: personal\ndate_added: \"2026-02-27\"\n---\n\n# LibreOffice Writer\n\n## Overview\n\nLibreOffice Writer skill for creating, editing, converting, and automating document workflows using the native ODT (OpenDocument Text) format.\n\n## When to Use This Skill\n\nUse this skill when:\n- Creating new documents in ODT format\n- Converting documents between formats (ODT \u003C-> DOCX, PDF, HTML, RTF, TXT)\n- Automating document generation workflows\n- Performing batch document operations\n- Creating templates and standardized document formats\n\n## Core Capabilities\n\n### 1. Document Creation\n- Create new ODT documents from scratch\n- Generate documents from templates\n- Create mail merge documents\n- Build forms with fillable fields\n\n### 2. Format Conversion\n- ODT to other formats: DOCX, PDF, HTML, RTF, TXT, EPUB\n- Other formats to ODT: DOCX, DOC, RTF, HTML, TXT\n- Batch conversion of multiple documents\n\n### 3. Document Automation\n- Template-based document generation\n- Mail merge with data sources (CSV, spreadsheet, database)\n- Batch document processing\n- Automated report generation\n\n### 4. Content Manipulation\n- Text extraction and insertion\n- Style management and application\n- Table creation and manipulation\n- Header\u002Ffooter management\n\n### 5. Integration\n- Command-line automation via soffice\n- Python scripting with UNO\n- Integration with workflow automation tools\n\n## Workflows\n\n### Creating a New Document\n\n#### Method 1: Command-Line\n```bash\nsoffice --writer template.odt\n```\n\n#### Method 2: Python with UNO\n```python\nimport uno\n\ndef create_document():\n    local_ctx = uno.getComponentContext()\n    resolver = local_ctx.ServiceManager.createInstanceWithContext(\n        \"com.sun.star.bridge.UnoUrlResolver\", local_ctx\n    )\n    ctx = resolver.resolve(\n        \"uno:socket,host=localhost,port=8100;urp;StarOffice.ComponentContext\"\n    )\n    smgr = ctx.ServiceManager\n    doc = smgr.createInstanceWithContext(\"com.sun.star.text.TextDocument\", ctx)\n    text = doc.Text\n    cursor = text.createTextCursor()\n    text.insertString(cursor, \"Hello from LibreOffice Writer!\", 0)\n    doc.storeToURL(\"file:\u002F\u002F\u002Fpath\u002Fto\u002Fdocument.odt\", ())\n    doc.close(True)\n```\n\n#### Method 3: Using odfpy\n```python\nfrom odf.opendocument import OpenDocumentText\nfrom odf.text import P, H\n\ndoc = OpenDocumentText()\nh1 = H(outlinelevel='1', text='Document Title')\ndoc.text.appendChild(h1)\ndoc.save(\"document.odt\")\n```\n\n### Converting Documents\n\n```bash\n# ODT to DOCX\nsoffice --headless --convert-to docx document.odt\n\n# ODT to PDF\nsoffice --headless --convert-to pdf document.odt\n\n# DOCX to ODT\nsoffice --headless --convert-to odt document.docx\n\n# Batch convert\nfor file in *.odt; do\n    soffice --headless --convert-to pdf \"$file\"\ndone\n```\n\n### Template-Based Generation\n```python\nimport subprocess\nimport tempfile\nfrom pathlib import Path\n\ndef generate_from_template(template_path, variables, output_path):\n    with tempfile.TemporaryDirectory() as tmpdir:\n        subprocess.run(['unzip', '-q', template_path, '-d', tmpdir])\n        content_file = Path(tmpdir) \u002F 'content.xml'\n        content = content_file.read_text()\n        for key, value in variables.items():\n            content = content.replace(f'${{{key}}}', str(value))\n        content_file.write_text(content)\n        subprocess.run(['zip', '-rq', output_path, '.'], cwd=tmpdir)\n    return output_path\n```\n\n## Format Conversion Reference\n\n### Supported Input Formats\n- ODT (native), DOCX, DOC, RTF, HTML, TXT, EPUB\n\n### Supported Output Formats\n- ODT, DOCX, PDF, PDF\u002FA, HTML, RTF, TXT, EPUB\n\n## Command-Line Reference\n\n```bash\nsoffice --headless\nsoffice --headless --convert-to \u003Cformat> \u003Cfile>\nsoffice --writer    # Writer\nsoffice --calc      # Calc\nsoffice --impress   # Impress\nsoffice --draw      # Draw\n```\n\n## Python Libraries\n\n```bash\npip install odfpy     # ODF manipulation\npip install ezodf     # Easier ODF handling\n```\n\n## Best Practices\n\n1. Use styles for consistency\n2. Create templates for recurring documents\n3. Ensure accessibility (heading hierarchy, alt text)\n4. Fill document metadata\n5. Store ODT source files in version control\n6. Test conversions thoroughly\n7. Embed fonts for PDF distribution\n8. Handle conversion failures gracefully\n9. Log automation operations\n10. Clean temporary files\n\n## Troubleshooting\n\n### Cannot open socket\n```bash\nkillall soffice.bin\nsoffice --headless --accept=\"socket,host=localhost,port=8100;urp;\"\n```\n\n### Conversion Quality Issues\n```bash\nsoffice --headless --convert-to pdf:writer_pdf_Export document.odt\n```\n\n## Resources\n\n- [LibreOffice Writer Guide](https:\u002F\u002Fdocumentation.libreoffice.org\u002F)\n- [LibreOffice SDK](https:\u002F\u002Fwiki.documentfoundation.org\u002FDocumentation\u002FDevGuide)\n- [UNO API Reference](https:\u002F\u002Fapi.libreoffice.org\u002F)\n- [odfpy](https:\u002F\u002Fpypi.org\u002Fproject\u002Fodfpy\u002F)\n\n## Related Skills\n\n- calc\n- impress\n- draw\n- base\n- docx-official\n- pdf-official\n- workflow-automation\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,211,105,"2026-05-16 13:26:12",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"效率工具","productivity","mdi-lightning-bolt-outline","文档处理、数据分析、自动化工作流",4,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"文档处理","document","mdi-file-document-outline","PDF\u002FWord\u002FExcel\u002FPPT 处理",1,23,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"75c93f22-d54a-40d2-a853-0f1ab9c31df3","1.0.0","writer.zip",2376,"uploads\u002Fskills\u002F69a4de34-3fef-4d69-998d-798bab3437ee\u002Fwriter.zip","e13830d9f1eeacfb3837827e72823d3a1d7926251211cba91bca631479ba5435","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":5354}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]