by sickn33
使用命令行和Python UNO API自动化LibreOffice Impress演示文稿创建、ODP、PPTX和PDF之间的格式转换,以及使用模板生成幻灯片。
1. 打开 Claude 聊天界面
2. 点击下方 "📋 复制" 按钮
3. 粘贴到 Claude 聊天框中并发送
4. 输入 "使用 impress 技能" 开始使用
=== impress 技能 === 作者: sickn33 描述: 使用命令行和Python UNO API自动化LibreOffice Impress演示文稿创建、ODP、PPTX和PDF之间的格式转换,以及使用模板生成幻灯片。 使用方法: 1. 调用技能: "使用 impress 技能" 2. 提供相关信息: 根据技能要求提供必要参数 3. 查看结果: 技能会返回处理结果 示例: "使用 impress 技能,帮我分析一下这段代码"
这种方法适用于所有 Claude 用户,不需要安装额外工具。
office
safe
LibreOffice Impress skill for creating, editing, converting, and automating presentation workflows using the native ODP (OpenDocument Presentation) format.
Use this skill when:
soffice --impress template.odp
import uno
def create_presentation():
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.presentation.PresentationDocument", ctx)
slides = doc.getDrawPages()
slide = slides.getByIndex(0)
doc.storeToURL("file:///path/to/presentation.odp", ())
doc.close(True)
# ODP to PPTX
soffice --headless --convert-to pptx presentation.odp
# ODP to PDF
soffice --headless --convert-to pdf presentation.odp
# PPTX to ODP
soffice --headless --convert-to odp presentation.pptx
# Batch convert
for file in *.odp; do
soffice --headless --convert-to pdf "$file"
done
import subprocess
import tempfile
from pathlib import Path
def generate_from_template(template_path, content, output_path):
with tempfile.TemporaryDirectory() as tmpdir:
subprocess.run(['unzip', '-q', template_path, '-d', tmpdir])
content_file = Path(tmpdir) / 'content.xml'
content_xml = content_file.read_text()
for key, value in content.items():
content_xml = content_xml.replace(f'${{{key}}}', str(value))
content_file.write_text(content_xml)
subprocess.run(['zip', '-rq', output_path, '.'], cwd=tmpdir)
return output_path
soffice --headless
soffice --headless --convert-to <format> <file>
soffice --impress # Impress
pip install ezodf # ODF handling
pip install odfpy # ODF manipulation
killall soffice.bin
soffice --headless --accept="socket,host=localhost,port=8100;urp;"
View Count
0
Download Count
0
Favorite Count
0
Quality Score
69