office 封装层:本地直跑(AGENT_LOCAL_PICK)没有预览网关,不发 ui_card、 不 POST __pv-touch;watch/unwatch 与 mark/goto 族放行,watch 改后台拉起 + 等端口就绪后报地址退出(前台透传会卡到 terminal 超时)。 x2pdf:文本类分派改为 WeasyPrint → 无头浏览器 → LibreOffice,浏览器后端只需 装了 Chrome 系,不要求用户为转 PDF 现编 pango;CSS/base 注入到 head,无 @page 时 补 A4(浏览器默认 Letter)。吞掉 WeasyPrint 导入失败时裸 print 到 stdout 的告警。 对外文案只讲结果(排版降级/无可用排版能力),实现细节留在 AGENTS.md。
1.6 KiB
1.6 KiB
x2pdf
ModuleNotFoundError(markdown):把依赖装进 $AGENT_SKILLS_DEPS
python3 -m pip install --upgrade --target "$AGENT_SKILLS_DEPS" -r "$(dirname "$AGENT_SKILLS_DEPS")/x2pdf/requirements.txt"
后端缺哪个,代价多大
| 后端 | 缺了的影响 | 怎么补 |
|---|---|---|
| LibreOffice | Office 类(docx/xlsx/pptx)完全不能转,必装 | Linux apt install libreoffice;macOS brew install --cask libreoffice;Windows winget install TheDocumentFoundation.LibreOffice |
| 浏览器 | 文本类落到 LibreOffice,CSS 基本失效 | 通常不用装:已有 Chrome / Chromium / Edge 就自动用 |
| WeasyPrint | 文本类没有页码、@page 精确排版失效 |
先装 Python 包(见上),再补系统库 pango/cairo:Linux apt install libpango-1.0-0 libpangocairo-1.0-0 libcairo2;macOS brew install pango;Windows 补 GTK 运行库,装不上就跳过 |
报「没有可用的 PDF 排版能力」时:文本类有三个后端可退,按上表从便宜到贵补,别一次全装。 输出带着「排版降级」(无页码/边距偏差)不是失败,是后端不全,按需补。 系统级安装(几百 MB,老系统上可能源码编译十几分钟)先跟用户说清代价,由他决定装还是接受降级。
装完必须验证
pip install 成功不代表能用,缺系统库时 import 就炸:
python3 -c "import weasyprint; print(weasyprint.__version__)"
报 could not import some external libraries = 系统库(pango/cairo)还没到位,不是 Python 包的问题。