用于报告、论文及结构化文档的HTML优先PDF生成技能,在从HTML输出PDF前必须应用。
范围与操作合同是一项面向实际任务的技能,主要用于此技能规范了 HTML 的编写和转换到打印质量 PDF. 2. 初级输出目标 :. 稳定 pugination and 可预测 的 Linux 运行时间。它将相关步骤、工具调用和结果整理方式集中到统一流程中,帮助使用者更快完成目标并减少重复操作。
实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。
执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;涉及批量任务时,还应保存进度,避免中断后重复操作。
本技能专用于编写 HTML 并将其转换为印刷级 PDF。
主要输出目标:
对于 HTML→PDF 转换,仅允许使用 html_to_pdf。
禁止行为:
原因:图像拼接路径会损害文字质量,并导致分页不连续。
counter-reset、counter-increment、counter())。执行前须对任务进行意图分类:
| 意图 | 典型用户请求 | 流水线 |
|---|---|---|
| Build | “写一份报告并导出 PDF” | build-pdf |
| Transform | “把这篇内容翻译后做成 PDF” | transform-pdf |
| Existing PDF ops | “提取/合并/拆分 PDF” | process-existing-pdf |
| LaTeX explicit | “请用 LaTeX/.tex/Tectonic” | latex-compile |
澄清策略:
重要澄清行为规范:
本技能推荐引文格式:IEEE 数字编号制(IEEE numeric)。
参考文献列表示例:
[1] R. Patel and L. Chen, "A comparative study on model routing," Journal of Applied AI, vol. 8, no. 3, pp. 44-58, 2025.
[2] M. Rivera, Systems Design Handbook, 2nd ed. New York, NY, USA: Northbridge Press, 2024.
[3] T. Huang, "Model evaluation checklist," Research Notes, https://example.org/eval (accessed Feb. 14, 2026).
在转换已有材料(翻译/重写/格式化)时,须保持源内容保真度:
href 中的目标 URL。preserve_links=true。采用三阶段校验:
![]()
标签数量| 模式 | 不稳定原因 | 替代方案 |
|---|---|---|
| CSS content counters 实现编号 | 分页 DOM 变动可能导致编号错乱 | 在标记中显式声明标签 |
| 渲染时动态加载 JS 图表库 | 与打印分页逻辑冲突 | 预渲染静态图表 |
| 大量使用 emoji / 图标排版 | Linux 环境下回退表现不一致 | 使用纯文本标签 |
图表图像策略:
width > height),以减少分页断点异常。/* 保证可打印区块位于页面宽度内 */
pre, table, figure, img, svg, .diagram, blockquote, .eq-block {
max-inline-size: 100%;
box-sizing: border-box;
}
pre {
overflow-x: auto;
white-space: pre-wrap;
overflow-wrap: anywhere;
}
figure img, figure svg {
max-inline-size: 82%;
max-block-size: 42vh;
height: auto;
}
table { overflow-x: auto; }
.katex-display { overflow-x: auto; }
code { overflow-wrap: anywhere; }
a { overflow-wrap: anywhere; }
tr { break-inside: avoid; }
body {
text-align: justify;
text-align-last: start;
}
@page {
size: A4;
margin: 2.4cm 1.9cm;
@top-center { content: string(doc_title); }
@bottom-center { content: counter(page); }
}
@page :first {
@top-center { content: none; }
@bottom-center { content: none; }
}
@page titlepage {
@top-center { content: none; }
@bottom-center { content: none; }
}
@page contents {
@top-center { content: none; }
@bottom-center { content: none; }
}
body { string-set: doc_title ""; }
h1 { string-set: doc_title content(); }
.cover-page { page: titlepage; }
.toc-sheet { page: contents; }
分页注意事项:
break-inside: avoid。thead { display: table-header-group; } 保证表头重复显示。默认目标是 印刷学术风格(print-academic),而非仪表盘美学风格。
应避免:
应优先采用:
字号比例建议:
全出血基线样式:
*,
*::before,
*::after { box-sizing: border-box; }
html, body {
margin: 0;
padding: 0;
}
@page :first {
margin: 0;
}
.cover-page {
inline-size: 210mm;
block-size: 297mm;
position: relative;
display: grid;
place-items: center;
overflow: hidden;
break-after: page;
}
封面变体:
若使用图像背景,请勿使用 CSS background-image;应使用绝对定位的 :
...
.cover-photo {
position: absolute;
inset: 0;
inline-size: 100%;
block-size: 100%;
object-fit: cover;
object-position: center;
z-index: 0;
}
.cover-layer {
position: absolute;
inset-block-start: 50%;
inset-inline-start: 50%;
transform: translate(-50%, -50%);
z-index: 1;
}
使用标记中显式声明的标签,而非 CSS 计数器。
Architecture Overview
Latency by Scenario
...
$$f(x)=x^2+1$$
figcaption::before {
content: attr(data-caption) " ";
font-weight: 700;
}
caption::before {
content: attr(data-caption) " ";
font-weight: 700;
}
.eq-block::after {
content: attr(data-eq);
float: right;
}
锚点放置规则:
id 设置于最高层级逻辑容器(如 figure、table 或章节包装器),而非内联的标题文本上。带自动计算页码的 TOC 示例:
.toc-list {
list-style: none;
margin: 0;
padding: 0;
}
.toc-list li { margin: 0.45em 0; }
.toc-list a {
display: flex;
gap: 0.5em;
color: inherit;
text-decoration: none;
}
.toc-list a::after {
margin-inline-start: auto;
content: target-counter(attr(href url), page);
}
可选的文中页码引用:
a.page-ref::after {
content: " (p." target-counter(attr(href url), page) ")";
opacity: 0.72;
font-size: 0.86em;
}
定义块(definition block):
.definition {
border-inline-start: 3px solid #475569;
padding-inline-start: 1rem;
margin: 1rem 0;
}
.definition-title { font-weight: 700; }
.definition-body { font-style: italic; }
流程块(procedure block):
.procedure {
border: 1px solid #cbd5e1;
padding: 0.75rem;
background: #f8fafc;
}
固定尺寸居中徽章必须使用 Flexbox:
.badge-index {
inline-size: 1.7em;
block-size: 1.7em;
display: inline-flex;
align-items: center;
justify-content: center;
border: 1px solid #cbd5e1;
border-radius: 999px;
}
参考文献锚点一致性要求:
[n] 必须唯一对应一个 。a.citation {
color: #1f2937;
text-decoration: none;
vertical-align: super;
font-size: 0.78em;
}
.ref-list li {
padding-inline-start: 2em;
text-indent: -2em;
}
分页式脚注模式:
.fn {
float: footnote;
}
.fn::footnote-call {
content: counter(footnote);
vertical-align: super;
font-size: 0.78em;
}
.fn::footnote-marker {
content: counter(footnote) ". ";
}
@page {
@footnote {
margin-top: 1.1em;
border-top: 1px solid #d1d5db;
padding-top: 0.55em;
}
}
当页数或版面未达预期目标时,按以下优先级顺序调整:
| 问题现象 | 首选调整项 | 次选调整项 | 应避免操作 |
|---|---|---|---|
| 页数超出目标 | 缩小标题字号 | 略微降低行高 | 激进压缩正文字号 |
| 页数低于目标 | 提高行高 | 略微增大页边距 | 添加低价值填充文本 |
| 表格超出页面宽度 | 减小单元格内边距 | 允许长词自动换行 | 强制设定表格固定宽度 |
| 图表破坏版面 | 降低图表最大宽/高限制 | 将图表移至段落边界附近 | 在大型父容器上设置 avoid |
| 文字显得拥挤 | 提升行高 | 略微增大左右页边距 | 大幅跳变标题字号 |
| Resume 排版过疏或过密 | 优先调整页边距 | 再调节标题字号比例 | 静默更改章节顺序 |
最终交付前须运行全部关卡检查。
href。preserve_links=true。![]()
标签数量及其映射关系id 应置于顶层容器(figure、章节包装器等),而非内部文本节点。target-counter)。相关专题
热门下载
相关下载
精品课程
共1课时 | 499人学习
共0课时 | 0人学习
共1课时 | 177人学习
最新文章