Skip to content
Back to skills

lekhan

ASecurity

Create print-ready PDFs from HTML or Markdown by laying out a self-contained document and printing it with headless Chromium. Use when the user asks to make a PDF, export as PDF, design a one-pager, produce a report PDF, turn notes into a printable brief, or generate a paginated handout. Also use for résumés, proposals, and other designed multi-page documents that need predictable page breaks.

  • 5 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 4, 2026
ai-agentspythonrustbash

Works with

  • terminal
  • cli

Security analysis

A92/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 5 files and shows the line behind each finding

Scanned December 4, 2026

npx -y skills add nayan-kunwar/lekhan-pdf-skill --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of lekhan?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for lekhan
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nayan-kunwar-lekhan/badge)](https://www.skillsdirectory.com/skills/nayan-kunwar-lekhan)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: lekhan
description: >
  Create print-ready PDFs from HTML or Markdown by laying out a self-contained
  document and printing it with headless Chromium. Use when the user asks to
  make a PDF, export as PDF, design a one-pager, produce a report PDF, turn
  notes into a printable brief, or generate a paginated handout. Also use for
  résumés, proposals, and other designed multi-page documents that
  need predictable page breaks.
---

# Lekhan

Lekhan builds a PDF by writing a self-contained HTML+CSS document and printing
it with headless Chromium. Designed work (a one-pager, a report, a proposal)
uses explicit `.page` boxes — one box per sheet — starting from
`templates/document.html`. Flowing Markdown is fine for drafts and notes;
Chromium paginates those itself.

Do not invent a new layout system. Copy the template, replace the copy, render,
then inspect the page PNGs before you deliver the file.

## Workflow

1. **Plan the pages.** Decide the paper size (A4 by default, Letter if asked),
   the page count, and what belongs on each sheet: cover, narrative, metrics,
   tables, close. If a table or section will not fit, split it yourself across
   two `.page` sections rather than hoping the browser will break it cleanly.

2. **Start from the template.** Copy `templates/document.html`. It already has
   a cover, an interior page, a metric grid, a table, a callout, footers with
   page numbers, `:root` color tokens, `@page` rules, and `break-inside: avoid`
   on the blocks that should stay together. Keep the CSS tokens; restyle only
   when the document needs a different voice.

3. **Fill the content.** Replace placeholder titles, metrics, and rows with
   real copy. Keep each `.page` box at the paper size (`210mm × 297mm` for A4,
   `8.5in × 11in` for Letter). Do not let a sheet run long and “spill” — there
   is no automatic overflow onto the next box. For Markdown input instead of a
   designed layout, pass a `.md` file to the render script (it wraps the
   document via `scripts/md_to_html.py`).

4. **Render.** From the skill root:

   ```bash
   python scripts/render_pdf.py path/to/document.html -o out.pdf --png-dir qa --expect-pages N
   ```

   Add `--page-size Letter` when the brief calls for US letter. The script
   prints with backgrounds on, writes one PNG per PDF page, warns if a `.page`
   box overflows or a font/image fails to load, and prints the page count and
   file size.

5. **Inspect the PNGs.** Open every page image. Do not trust a clean exit
   alone. Check the list below and fix the HTML when something is off.

6. **Fix, then render again.** Adjust spacing, type size, or how content is
   split across `.page` boxes. Repeat until the PNGs are clean and
   `--expect-pages` matches.

7. **Deliver.** Send the finished PDF. Mention the page count and paper size.
   Keep the PNGs around if the user may want a revision.

## QA checklist

Look at each page PNG, not only the terminal output:

- **Overflow.** Nothing is clipped at the edge of a `.page` box. The script
  warns when a box’s scroll size exceeds its layout size, or when a child
  sticks out of the page bounds — treat every warning as a fail.
- **Orphan headings.** No heading sits alone at the bottom of a sheet. Move
  the heading onto the next `.page` with its body.
- **Split tables.** A table is not cut mid-row. If it is long, split it by
  hand across two pages and repeat the header row.
- **Fonts.** Body and display text render in the intended family, not a
  fallback surprise. Avoid networked webfonts unless you wait on
  `document.fonts.ready` (the script already does) and have a system-font
  fallback stack.
- **Page count.** The PDF has the number of pages you planned. No blank
  trailing sheet. `--expect-pages N` should pass.
- **Contrast.** Text is readable on the paper color, including muted labels,
  footer text, and callout copy. Metrics and table headers stay legible when
  the PDF is printed in grayscale.

## Examples to copy from

Finished, rendered samples live in `examples/`. Open the closest one and reuse its structure:

- `examples/technical-guide/`: multi-page explainer with inline SVG diagrams, code blocks, and tables.
- `examples/resume/`: dense one-page, two-column layout.
- `examples/data-report/`: cover on a named `@page`, KPI cards, SVG charts, running page numbers, and a long table with a repeating header (`thead { display: table-header-group; }`).
- `examples/flyer/`: full-bleed poster.
- `examples/certificate/`: A4 landscape with `@page { size: A4 landscape; }`.
- `examples/markdown-notes/`: the quick Markdown path.

Choose fixed `.page` boxes for designed layouts, and `@page` margins with normal flow for
long, flowing content. Mark purely decorative SVG with `aria-hidden="true"` so the overflow
checks ignore it.

## Script notes

- `scripts/render_pdf.py` accepts `.html` or `.md`. Markdown is converted
  first, then printed.
- `--page-size A4|Letter` overrides the document's paper size; without it the document's own
  `@page` size wins. `--landscape` prints in landscape.
- `--png-dir` writes `<stem>-page-1.png`, `<stem>-page-2.png`, and so on.
  PNGs are produced with pypdfium2, or with `pdftoppm` if pypdfium2 is missing.
- Dependencies: `pip install playwright pypdf pypdfium2 markdown pillow`, then
  `python -m playwright install chromium`.

Files in this skill

  • SKILL.md5.2 KB
  • requirements.txt70 B
  • scripts/md_to_html.py5.8 KB
  • scripts/render_pdf.py15.5 KB
  • templates/document.html12.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.