convez.ai
Skill
xntj-ai

onepage-pdf

xntj-ai/onepage-pdf

Ver no GitHub
InicialPluginScore · de 0 a 100

HTML to single continuous-page PDF (no pagination) - render-then-crop pipeline + Claude Code skill

Instalação

$npx convez-ai xntj-ai/onepage-pdf

1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.

Métricas

Estrelas
11
Forks
1
Acompanhando
0
Saúde
42%
Último commit
há 5 meses
Versão
—
Issues abertas
0
Contribuidores
1

README

A tradução para o português deste README ainda está na fila.

onepage-pdf

Convert an HTML page into a single continuous-page PDF — one tall page, no pagination breaks, desktop layout preserved, text selectable.

为长滚动式 HTML(提案、报告、落地页)生成不分页的单页 PDF,桌面布局原样保留。

Why

Chrome's print pipeline cannot tell you the printed height of a page up front: print media queries evaluate against the default paper width (~741px) instead of your @page size, viewport units drift, web fonts shift line heights, and the px→inch→pt conversion rounds badly enough to spawn phantom pages (puppeteer#2278).

So this tool never predicts the height. It renders onto an oversized "bedrock" page with headless Chrome, then measures the real content bottom from the PDF itself (PyMuPDF render-level bbox log) and crops MediaBox + CropBox to fit. Height is cropped, not calculated — the result is exact by construction.

Requirements

  • Python 3.10+ with pymupdf
  • A local Chrome or Edge (auto-detected, or pass --chrome)

Usage

python scripts/onepage_pdf.py input.html -o output.pdf --width 1280

Try it on the bundled demo (gradient background, 3-column grid, glassmorphism, scroll-reveal animations, CJK typography):

python scripts/onepage_pdf.py examples/demo.html -o demo.pdf \
    --extra-css examples/demo-fixes.css

Options

FlagDefaultPurpose
--width1280Page width in CSS px (snapped to 8px to dodge MediaBox rounding)
--bedrock18000Initial oversized height; auto-doubles on overflow
--padding32Whitespace kept below the content, px
--extra-css—CSS appended to the injected print styles (breakpoint locks, glass fallbacks)
--replace—JSON [["old","new"],...] applied before rendering (redaction)
--forbid—Word list; abort if any survives in the HTML or the final PDF text
--cropvectorvector (bbox log) or pixel (raster row scan) content detection
--virtual-time10000Chrome --virtual-time-budget ms for JS-driven pages

What gets handled for you

  • Scroll-reveal animations forced visible (fade*/reveal*/animate*/aos)
  • Background colors and gradients preserved (print-color-adjust: exact)
  • background-attachment: fixed normalized (Chrome paints it on page 1 only)
  • Overflow auto-retry: bedrock doubles until the content fits on one page
  • Both MediaBox and CropBox rewritten identically (viewer compatibility)
  • Single-page assertion + redaction leak check against the PDF text layer
  • Warns when output exceeds the 14400pt Acrobat limit (Chrome/Firefox/WeChat render larger pages fine)

What you still do by hand

Responsive breakpoints ≥741px fire during print and collapse desktop grids — lock them back with --extra-css (see examples/demo-fixes.css). Same file is the place for glassmorphism fallbacks: backdrop-filter blur is silently dropped in PDF output (crbug 40895818).

The full rationale — two-viewport media query behavior, the hidden 1.5× print shrink, PDF size limits, CJK font pitfalls — is documented in references/mechanics.md.

As a Claude Code skill

This repo is also an agent skill: drop it into ~/.claude/skills/onepage-pdf and Claude Code will inspect the source HTML, generate the breakpoint locks itself, run the conversion and eyeball-verify the output. See SKILL.md.

License

MIT

Ver o original no GitHub

Bom para

Relacionados