feat(skills): office 本地放行 watch、x2pdf 加浏览器后端
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。
This commit is contained in:
+20
-7
@@ -1,16 +1,29 @@
|
||||
# x2pdf
|
||||
|
||||
`ModuleNotFoundError`(`markdown`)或提示 WeasyPrint 不可用:把依赖装进 `$AGENT_SKILLS_DEPS`
|
||||
`ModuleNotFoundError`(`markdown`):把依赖装进 `$AGENT_SKILLS_DEPS`
|
||||
|
||||
```sh
|
||||
python3 -m pip install --upgrade --target "$AGENT_SKILLS_DEPS" -r "$(dirname "$AGENT_SKILLS_DEPS")/x2pdf/requirements.txt"
|
||||
```
|
||||
|
||||
WeasyPrint 还要系统库 pango/cairo:Linux `apt install libpango-1.0-0 libpangocairo-1.0-0 libcairo2`;
|
||||
macOS `brew install pango`;Windows 装不起来就跳过——有 LibreOffice 时文本类会自动回落。
|
||||
## 后端缺哪个,代价多大
|
||||
|
||||
Office 类(docx/xlsx/pptx)报「未找到 LibreOffice」:装一个 LibreOffice
|
||||
(Linux `apt install libreoffice`;macOS `brew install --cask libreoffice`;
|
||||
Windows `winget install TheDocumentFoundation.LibreOffice`)。
|
||||
| 后端 | 缺了的影响 | 怎么补 |
|
||||
|---|---|---|
|
||||
| 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 运行库,装不上就跳过 |
|
||||
|
||||
装了 LibreOffice 后文本类也能用(回落路径,`page` 的边距/页码与部分 CSS 不生效),此时不必装 pango。
|
||||
报「没有可用的 PDF 排版能力」时:文本类有三个后端可退,按上表从便宜到贵补,别一次全装。
|
||||
输出带着「排版降级」(无页码/边距偏差)不是失败,是后端不全,按需补。
|
||||
系统级安装(几百 MB,老系统上可能源码编译十几分钟)先跟用户说清代价,由他决定装还是接受降级。
|
||||
|
||||
## 装完必须验证
|
||||
|
||||
`pip install` 成功不代表能用,缺系统库时 import 就炸:
|
||||
|
||||
```sh
|
||||
python3 -c "import weasyprint; print(weasyprint.__version__)"
|
||||
```
|
||||
|
||||
报 `could not import some external libraries` = 系统库(pango/cairo)还没到位,不是 Python 包的问题。
|
||||
|
||||
Reference in New Issue
Block a user