--- name: x2pdf description: 通用 PDF 转换:Markdown / HTML / txt / Word / Excel / PPT 转 PDF(推荐生成 PDF 一律用本技能,不要手写排版脚本) input_schema: type: object properties: input: type: string description: 输入文件路径,支持 .md/.markdown/.txt/.html/.htm/.docx/.xlsx/.pptx/.odt/.ods/.odp output: type: string description: 输出 PDF 路径(可选,默认与输入同名) css: type: string description: 自定义 CSS 文件路径(可选,仅对 md/html/txt 生效,优先级最高) page: type: object description: 页面设置(可选,仅对 md/html/txt 生效;Office 文档版式由原文件决定,忽略本参数) properties: size: type: string description: 页面尺寸,默认 A4;也可传 "A5"、"letter"、"210mm 297mm" 等 margin: type: string description: 页边距,默认 20mm;可单值或 "上 右 下 左" 四值 font_size: type: string description: 正文字号,默认 10.5pt;标题/代码等按 em 相对缩放,压页数时调小本值 required: [input] output_schema: type: string description: 生成的 PDF 文件路径 --- ## 功能说明 统一 PDF 转换入口,按扩展名自动分派两条渲染路径: - **md / txt / html → WeasyPrint**(CSS 排版,字体走 fontconfig,中文用系统文泉驿/Noto,无需字体文件) - **docx / xlsx / pptx / odt / ods / odp → LibreOffice headless**(忠于原文档版式,`page`/`css` 参数不生效) ### Markdown 输入(`.md` / `.markdown`) - 标准语法之外,支持表格(管道语法)、围栏代码块(```/~~~)、脚注、定义列表、 标题锚点、属性列表、HTML 内联(Markdown `extra` 全家桶); - 文首 YAML front matter 当元数据剔除,不渲染; - 图片:相对路径按 **输入文件所在目录** 解析,也支持绝对路径与 http(s) 图片; - 自动套用默认 CSS(见下)。 ### txt 输入(`.txt`) - **不解析**,按原文转义后整篇以等宽 `
` 渲染(保换行,超长行自动折行)。 ### HTML 输入(`.html` / `.htm`) - 文档原样渲染,**不套默认 CSS**——自带 `