name: single-page-pdf-export description: "Use when the user asks to export a local HTML file, web page, or invitation page to a single-page PDF, a no-pagination PDF, a long PDF with auto-calculated height, or a PDF without headers and footers. Trigger on phrases like 单页 PDF, 不分页, 自动计算长度, 长图 PDF, 去掉页眉页脚, export HTML to single-page PDF, or print page to one PDF page."
Single-Page PDF Export Skill
Export an HTML file or loaded page to a single-page PDF whose height is calculated from the rendered content, with no browser header or footer.
Use This Skill For
- Local
.htmlfiles that should become a single long PDF - Pages that should not be split across multiple PDF pages
- Requests to remove browser print headers and footers
- Pages using viewport-height layouts like
min-h-screenthat break normal printing
Inputs To Resolve
Before exporting, determine:
- The source page:
- Local file path like
/user/test/page.html - Or a
file:///,http://, orhttps://URL
- Local file path like
- The output PDF path:
- If the user does not specify one, default to the source filename plus
-single-page.pdf
- If the user does not specify one, default to the source filename plus
Workflow
- Confirm the source exists if it is a local file.
- Ensure a Chromium-based browser is installed:
- Prefer Chrome, then Edge
- The asset script checks common Windows install paths and
CHROME_PATH
- Ensure Node dependencies are available in the current workspace:
- Install
puppeteer-corewithnpm install --no-save puppeteer-core - If you want to verify the resulting page count, also install
pdf-lib
- Install
- Run the bundled exporter:
node ./assets/export-single-page-pdf.mjs "<input>" "<output>"
- Validate the result:
- Confirm the PDF file exists
- If
pdf-libis available, verify page count is1
Validation Command
Use this only when you need to confirm that the PDF is truly single-page:
node --input-type=module -e "import { readFileSync } from 'node:fs'; import { PDFDocument } from 'pdf-lib'; const bytes = readFileSync(process.argv[1]); const pdf = await PDFDocument.load(bytes); console.log('pages=' + pdf.getPageCount());" "<output.pdf>"
Notes
- The exporter freezes
h-screenandmin-h-screenutilities to pixel values before printing. This avoids the common feedback loop where print page height changes the layout height and forces pagination. - The exporter disables animations and transitions before measuring the page.
- The exporter sets a custom print page size and zero margins, and disables browser headers and footers.
Troubleshooting
- If
puppeteer-coreis missing, install it in the workspace withnpm install --no-save puppeteer-core. - If Chrome or Edge is installed in a non-standard location, set
CHROME_PATHbefore running the exporter. - If the output still splits across pages, rerun the exporter with the bundled script instead of the browser's normal print dialog.
- If the source is a local file with relative assets, prefer passing the local file path instead of pasting raw HTML into a temporary file.
Expected Outcome
The result should be a single PDF page whose height matches the rendered document, with backgrounds preserved and no header or footer added by the browser.