make-pdf
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNutrient Make PDF
Nutrient Make PDF
Turn a Markdown or HTML file into a finished PDF through the Nutrient DWS Build API. The differentiator over local or Pandoc is the output stage: the same call can emit tagged, accessible PDF/UA or archival PDF/A, and stamp a diagonal text watermark — compliance work a plain HTML-to-PDF pipeline cannot do.
chromium --print-to-pdf通过Nutrient DWS Build API将Markdown或HTML文件转换为成品PDF。与本地或Pandoc相比,其差异化优势在于输出阶段:同一调用即可生成带标签的无障碍PDF/UA或归档PDF/A,还可添加斜向文本水印——这些合规性工作是普通HTML转PDF流程无法实现的。
chromium --print-to-pdfQuick Start
快速开始
All paths below are relative to this skill's directory (the directory containing and ).
scripts/assets/- Export the API key before generating (not needed for or the smoke test):
--html-only- (the same variable the sibling
export NUTRIENT_API_KEY="nutr_sk_..."scripts use;document-processor-apiis accepted as a fallback)NUTRIENT_DWS_API_KEY
- Generate:
bash
uv run scripts/make-pdf.py --input report.md --out report.pdfThe and packages are fetched automatically on first use.
markdown-it-pynutrient-dws以下所有路径均相对于本skill的目录(包含和的目录)。
scripts/assets/- 生成前需导出API密钥(使用或冒烟测试时无需此步骤):
--html-only- (与同级
export NUTRIENT_API_KEY="nutr_sk_..."脚本使用相同的变量;document-processor-api可作为备选)NUTRIENT_DWS_API_KEY
- 生成PDF:
bash
uv run scripts/make-pdf.py --input report.md --out report.pdf首次使用时会自动获取和包。
markdown-it-pynutrient-dwsCommon Tasks
常见任务
- Standard PDF from Markdown:
uv run scripts/make-pdf.py --input notes.md --out notes.pdf - Accessible PDF/UA (tagged, for WCAG/ADA/EAA requirements): add
--accessible - Archival PDF/A: add (conformance via
--pdfa, one of--pdfa-level, defaultpdfa-1a/1b/2a/2b/2u/3a/3u; only valid together withpdfa-2b)--pdfa - Draft watermark: add
--watermark DRAFT - Memo layout instead of the default document layout:
--template memo - Dark theme:
--theme dark - Title-page metadata: ,
--title,--subtitle,--author(or set them in Markdown frontmatter; CLI flags win)--date - Inspect the rendered HTML without calling the API (offline, no key): (Markdown input only — errors on
--html-onlyinput, which already is the HTML).html - Debug layout alongside the PDF: writes the intermediate HTML next to the PDF
--output-html - Batch: point at a directory (with
--input, required) to convert every--out <dir>/.mdin it — see Batch Conversion below.html
--accessible--pdfauv run scripts/make-pdf.py --help- 从Markdown生成标准PDF:
uv run scripts/make-pdf.py --input notes.md --out notes.pdf - 无障碍PDF/UA(带标签,满足WCAG/ADA/EAA要求):添加参数
--accessible - 归档PDF/A:添加参数(通过
--pdfa指定合规等级,可选值为--pdfa-level,默认值为pdfa-1a/1b/2a/2b/2u/3a/3u;仅当同时使用pdfa-2b时有效)--pdfa - 添加草稿水印:添加参数
--watermark DRAFT - 使用备忘录布局替代默认文档布局:
--template memo - 深色主题:
--theme dark - 标题页元数据:、
--title、--subtitle、--author(也可在Markdown前置元数据中设置;CLI参数优先级更高)--date - 仅查看渲染后的HTML而不调用API(离线模式,无需密钥):(仅支持Markdown输入——若输入为
--html-only文件会报错,因为其本身已是HTML).html - 调试布局并同时输出PDF:会在PDF旁写入中间HTML文件
--output-html - 批量转换:将指向目录(需配合
--input参数),转换目录中所有--out <dir>/.md文件——详见下方批量转换部分.html
--accessible--pdfauv run scripts/make-pdf.py --helpInput Rules
输入规则
- input is converted to HTML with a CommonMark+GFM parser (tables, strikethrough, task lists), then wrapped in the selected template with the theme CSS inlined — one self-contained HTML file is uploaded.
.md - input is uploaded as-is; template, theme, and metadata flags do not apply and a warning names any that were passed. Use it when you already have styled HTML.
.html - YAML frontmatter in Markdown (,
title,subtitle,author,date,template) controls the cover block; CLI flags override frontmatter. When no title is given anywhere, the firstthemeheading (or the filename) becomes the document title, so accessible output always has a real title.# - External images require network fetches on the DWS side and referenced local images are not uploaded in v1 — embed images as URIs if they must appear.
data:
- 输入会通过CommonMark+GFM解析器转换为HTML(支持表格、删除线、任务列表),然后用所选模板包裹并内联主题CSS——最终上传一个独立的HTML文件。
.md - 输入会直接上传;模板、主题和元数据参数不适用,若传入此类参数会发出警告。当您已有样式化HTML时可使用此方式。
.html - Markdown中的YAML前置元数据(、
title、subtitle、author、date、template)控制封面块;CLI参数会覆盖前置元数据。若未在任何地方指定标题,则第一个theme标题(或文件名)会成为文档标题,确保无障碍输出始终包含真实标题。# - 外部图片需要DWS端进行网络请求,而v1版本中不会上传本地引用的图片——若图片必须显示,请将其嵌入为URI格式。
data:
Verification (built in)
内置验证功能
Compliance outputs are verified, not just labeled. With or , the generated PDF is automatically checked after the build ( opts out); exit code 3 means "generated but failed verification" — the PDF is kept on disk so you can inspect it. If the verifier itself cannot run, the build still exits 3 rather than silently passing; is the explicit way to accept unverified output. Passing without a compliance flag is rejected up front — a standard PDF has no conformance claim to check.
--accessible--pdfa--no-verify--no-verify--verifyTwo assurance levels, and be honest about which one ran:
- Structural checks (always available, via ): the PDF/UA-1 claim marker (
scripts/verify-pdf.pyXMP part 1 — PDF/UA-2 documents are out of scope), tagged-structure signals (pdfuaid,MarkInfo), language,StructTreeRoot, and a non-empty document title — or the PDF/A identification (DisplayDocTitlepart + conformance, matched against the requested level). These catch real failures but are not a full conformance audit.pdfaid - Full audit (optional): if is installed on PATH, the verifier also runs veraPDF for a genuine conformance validation and reports its verdict. Recommend installing veraPDF when the user's requirement is regulatory (ADA/EAA deadlines, records retention).
verapdf
The verifier also works standalone on any PDF, including ones this skill did not create:
bash
uv run scripts/verify-pdf.py --input existing.pdf --profile pdfua
uv run scripts/verify-pdf.py --input archive-dir/ --profile pdfa --pdfa-level pdfa-2b合规输出会经过验证,而非仅添加标签。使用或参数时,生成的PDF会在构建后自动进行检查(可通过参数跳过);退出码3表示“已生成但验证失败”——PDF会保留在磁盘上供您检查。若验证器本身无法运行,构建仍会返回退出码3而非静默通过;是接受未验证输出的明确方式。若未指定合规参数却传递,会直接被拒绝——标准PDF无合规性声明可检查。
--accessible--pdfa--no-verify--no-verify--verify提供两种保证级别,请如实说明使用了哪一种:
- 结构检查(始终可用,通过):检查PDF/UA-1声明标记(
scripts/verify-pdf.pyXMP第1部分——暂不支持PDF/UA-2文档)、标签结构信号(pdfuaid、MarkInfo)、语言、StructTreeRoot以及非空文档标题——或检查PDF/A标识(DisplayDocTitle部分+合规等级,与请求的等级匹配)。这些检查可发现实际问题,但并非完整的合规性审计。pdfaid - 完整审计(可选):若PATH中安装了,验证器还会运行veraPDF进行真正的合规性验证并报告结果。当用户需求涉及法规要求(如ADA/EAA截止日期、记录保留)时,建议安装veraPDF。
verapdf
验证器也可独立用于任何PDF,包括非本skill生成的PDF:
bash
uv run scripts/verify-pdf.py --input existing.pdf --profile pdfua
uv run scripts/verify-pdf.py --input archive-dir/ --profile pdfa --pdfa-level pdfa-2bBatch Conversion
批量转换
--input <directory>.md.markdown.html.htmbash
uv run scripts/make-pdf.py --input reports/ --out pdfs/ --accessible- is required for directory input; outputs are named
--out <dir>.<stem>.pdf - Per-document metadata comes from each file's frontmatter, first heading, or filename — global
#/--titleare rejected for directory input. Shared flags (--subtitle,--template,--theme,--author,--date, compliance and verify flags) apply to every file.--watermark - Failures don't stop the batch: a summary on stderr lists converted/verified/failed counts, stdout still prints only created file paths. Exit 0 = all good, 1 = at least one build failed, 3 = builds succeeded but at least one verification failed.
- Batch mode never overwrites existing outputs (and refuses inputs that would collide on the same output name) — point at a fresh directory or remove stale files when regenerating.
--out
--input <directory>.md.markdown.html.htmbash
uv run scripts/make-pdf.py --input reports/ --out pdfs/ --accessible- 目录输入时必须指定参数;输出文件命名为
--out <dir>。<stem>.pdf - 每个文档的元数据来自各自文件的前置元数据、第一个标题或文件名——目录输入时不接受全局
#/--title参数。共享参数(--subtitle、--template、--theme、--author、--date、合规与验证参数)适用于所有文件。--watermark - 单个文件失败不会终止批量处理:stderr会输出转换/验证/失败数量的摘要,stdout仅打印已创建的文件路径。退出码0表示全部成功,1表示至少一个构建失败,3表示构建成功但至少一个验证失败。
- 批量模式永远不会覆盖现有输出(且会拒绝可能导致输出文件名冲突的输入)——重新生成时请将指向新目录或删除旧文件。
--out
Layout Honesty (Chromium limits)
布局限制说明(Chromium局限)
DWS renders HTML with headless Chromium (). That means standard print CSS works ( size and margins, / rules, ), but CSS Paged Media features Chromium does not implement will silently not render: running headers/footers, , and TOC page numbers. Do not promise page-numbered TOCs or running headers from CSS. If the user needs those, say so and offer the trade-offs (front-matter TOC without page numbers, or a different toolchain).
printToPDF@pagepage-break-*break-*@media printposition: running()counter(page)target-counter()DWS使用无头Chromium的渲染HTML。这意味着标准打印CSS可正常工作(尺寸和边距、/规则、),但Chromium未实现的CSS分页媒体功能不会生效:运行页眉/页脚、、目录页码。请勿承诺通过CSS生成带页码的目录或运行页眉。若用户需要这些功能,请说明情况并提供替代方案(不带页码的前置目录,或使用其他工具链)。
printToPDF@pagepage-break-*break-*@media printposition: running()counter(page)target-counter()Chaining Other Document Operations
与其他文档操作联动
Generation is one step. Related operations live in sibling plugins from the same marketplace:
- Sign, redact, or merge the produced PDF: the skill —
document-processor-api. Its scripts read the same/plugin install nutrient-dws@nutrient-skills; run them from that skill's own directory, e.g.NUTRIENT_API_KEY.uv run scripts/sign.py --input report.pdf --out report-signed.pdf - Make an EXISTING PDF accessible (auto-tag for PDF/UA): the skill —
remediate-pdf. This skill generates new PDFs; that one fixes old ones (and bundles the same/plugin install remediate-pdf@nutrient-skills).verify-pdf.py
生成只是一个步骤。相关操作可使用同一市场中的同级插件:
- 对生成的PDF进行签名、编辑或合并:使用skill——
document-processor-api。其脚本使用相同的/plugin install nutrient-dws@nutrient-skills;请在该skill的目录中运行,例如NUTRIENT_API_KEY。uv run scripts/sign.py --input report.pdf --out report-signed.pdf - 使现有PDF具备无障碍功能(自动添加PDF/UA标签):使用skill——
remediate-pdf。本skill用于生成新PDF;该skill用于修复旧PDF(并包含相同的/plugin install remediate-pdf@nutrient-skills)。verify-pdf.py
Implementation Rules
实现规则
- Fail fast with a clear message when (or the
NUTRIENT_API_KEYfallback) is missing (unlessNUTRIENT_DWS_API_KEY).--html-only - Never log the API key or request headers.
- Write outputs to explicit paths and print each created file path (one path per line on stdout; progress on stderr). A debug HTML path prints as soon as the file exists, even if a later build step fails.
- Non-zero exit on any failure; do not claim success unless the output file exists and is non-empty.
- 当(或备选
NUTRIENT_API_KEY)缺失时,立即终止并给出明确提示(使用NUTRIENT_DWS_API_KEY时除外)。--html-only - 绝不记录API密钥或请求头。
- 将输出写入指定路径,并打印每个已创建文件的路径(stdout每行打印一个路径;进度信息输出至stderr)。即使后续构建步骤失败,调试HTML路径也会在文件创建后立即打印。
- 任何失败均返回非零退出码;仅当输出文件存在且非空时才视为成功。
Validation
验证
Before calling this skill done after changes:
- — offline (no network, no key): every template x theme combination, Markdown feature survival (headings, tables, code blocks), verifier checks against constructed fixtures, and batch discovery.
uv run scripts/smoke-test.py - Generate one real PDF if a key is available; for compliance outputs let the built-in verification run (or run explicitly) rather than only checking the file is non-empty.
verify-pdf.py
修改完成后,需完成以下验证才能确认本skill可用:
- ——离线模式(无需网络和密钥):测试所有模板与主题的组合、Markdown特性保留情况(标题、表格、代码块)、验证器对构造测试用例的检查,以及批量文件发现功能。
uv run scripts/smoke-test.py - 若有可用密钥,生成一个真实PDF;对于合规输出,需运行内置验证(或显式运行),而非仅检查文件非空。
verify-pdf.py