lekhan-pdf-skill

agent
Security Audit
Warn
Health Warn
  • License — License: MIT
  • Description — Repository has a description
  • Active repo — Last push 0 days ago
  • Low visibility — Only 5 GitHub stars
Code Pass
  • Code scan — Scanned 2 files during light audit, no dangerous patterns found
Permissions Pass
  • Permissions — No dangerous permissions requested

No AI report is available for this listing yet.

SUMMARY

Lekhan — an agent skill that creates print-ready PDFs from HTML or Markdown with headless Chromium

README.md

Lekhan

An agent skill for creating print-ready PDFs. Lekhan writes a self-contained
HTML and CSS document, prints it with headless Chromium, then exports one PNG
per page so you can check the layout before you send the file.

The skill name is lekhan. This repository is lekhan-pdf-skill.

Designed documents (a one-pager, a report, a proposal) start from
templates/document.html and use one .page box per sheet of paper. Drafts
and notes can be passed in as Markdown; the script wraps them and lets
Chromium paginate.

Quick start

First page of Lekhan’s four-page technical guide

Open the sample PDF

Install in your agent

npx skills add nayan-kunwar/lekhan-pdf-skill --skill lekhan

Choose OpenCode, Codex, or Claude Code when prompted. This installs the skill, not its renderer dependencies. Before generating PDFs, follow the requirements in the environment where your agent runs.

Render the demo without an agent

With Git and Python 3.10+ installed, clone the repo and create a virtual environment:

git clone https://github.com/nayan-kunwar/lekhan-pdf-skill.git
cd lekhan-pdf-skill
python -m venv .venv

Activate it with source .venv/bin/activate on macOS or Linux, or .\.venv\Scripts\Activate.ps1 in Windows PowerShell. Then run:

python -m pip install -r requirements.txt
python -m playwright install chromium
python scripts/render_pdf.py examples/technical-guide/source.html -o guide.pdf --png-dir qa --expect-pages 4

Open guide.pdf for the result, or check qa/ for four PNGs, one per page. --expect-pages 4 makes the command fail if the PDF has a different page count.

Requirements

Python 3.10+ and Chromium via Playwright:

pip install playwright pypdf pypdfium2 markdown pillow
python -m playwright install chromium

A virtual environment is recommended:

python -m venv .venv
# macOS / Linux
source .venv/bin/activate
# Windows PowerShell
# .\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
python -m playwright install chromium

pypdfium2 is used to export page PNGs. If it is missing, the script falls
back to pdftoppm from Poppler (poppler-utils on most Linux distributions,
or the Poppler package on Windows).

Gallery

Six samples, each rendered by scripts/render_pdf.py. Every folder under examples/ holds the
source.html (or source.md), the finished PDF, and a preview.png of page 1. All people,
companies, and numbers in the samples are fictional.

Technical guide preview Résumé preview Data report preview
Technical guide · 4 pages Résumé · 1 page Data report · 5 pages
Flyer preview Certificate preview Markdown notes preview
Flyer · 1 page Certificate · 1 page, landscape Markdown notes · 2 pages
Sample What it demonstrates Source
Technical guide Multi-page explainer with a contents block, inline SVG diagrams, syntax-coloured code blocks, comparison tables, and callouts, laid out on explicit .page boxes. source.html
Résumé A dense one-page, two-column layout with a sidebar, skill bars, and chips. source.html
Data report Full-bleed cover on a named @page, KPI cards, inline SVG bar and line charts, running page numbers from @page margin boxes, and a long table whose header repeats on every page. source.html
Flyer A full-bleed poster with bold type, colour, and decorative SVG; every page edge is painted. source.html
Certificate A4 landscape through @page { size: A4 landscape; }, a decorative border, and signature lines. source.html
Markdown notes The quick path: plain Markdown in, a styled PDF out, with tables, task lists, and code. source.md

Regenerate any of them from the repository root:

python scripts/render_pdf.py examples/technical-guide/source.html -o examples/technical-guide/technical-guide.pdf --expect-pages 4
python scripts/render_pdf.py examples/resume/source.html          -o examples/resume/resume.pdf                   --expect-pages 1
python scripts/render_pdf.py examples/data-report/source.html     -o examples/data-report/data-report.pdf         --expect-pages 5
python scripts/render_pdf.py examples/flyer/source.html           -o examples/flyer/flyer.pdf                     --expect-pages 1
python scripts/render_pdf.py examples/certificate/source.html     -o examples/certificate/certificate.pdf         --expect-pages 1
python scripts/render_pdf.py examples/markdown-notes/source.md    -o examples/markdown-notes/markdown-notes.pdf   --expect-pages 2

Install the skill

Copy the repository into the skills folder of the agent you use. The folder
must be named lekhan so the skill name in SKILL.md matches the path.

OpenCode

Every project on this machine:

git clone https://github.com/nayan-kunwar/lekhan-pdf-skill.git ~/.config/opencode/skills/lekhan

One project only:

git clone https://github.com/nayan-kunwar/lekhan-pdf-skill.git .opencode/skills/lekhan

Codex

git clone https://github.com/nayan-kunwar/lekhan-pdf-skill.git ~/.codex/skills/lekhan

Restart Codex after copying the folder.

Claude Code

git clone https://github.com/nayan-kunwar/lekhan-pdf-skill.git ~/.claude/skills/lekhan

Via the skills CLI

npx skills add nayan-kunwar/lekhan-pdf-skill

If the CLI asks which agents to install for, pick the ones you use. If it
installs under a different folder name, rename that folder to lekhan.

Windows PowerShell

# Dependencies
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install playwright pypdf pypdfium2 markdown pillow
python -m playwright install chromium

# Install the skill for Codex (same idea for the other tools)
git clone https://github.com/nayan-kunwar/lekhan-pdf-skill.git $env:USERPROFILE\.codex\skills\lekhan

# Or copy a checkout you already have
Copy-Item -Recurse .\lekhan-pdf-skill $env:USERPROFILE\.codex\skills\lekhan
Copy-Item -Recurse .\lekhan-pdf-skill $env:USERPROFILE\.config\opencode\skills\lekhan
Copy-Item -Recurse .\lekhan-pdf-skill $env:USERPROFILE\.claude\skills\lekhan

# Render a sample
python scripts\render_pdf.py examples\technical-guide\source.html -o guide.pdf --png-dir qa --expect-pages 4

OpenCode on Windows also accepts:

Copy-Item -Recurse .\lekhan-pdf-skill $env:USERPROFILE\.config\opencode\skills\lekhan

Usage

python scripts/render_pdf.py examples/technical-guide/source.html -o guide.pdf --png-dir qa --expect-pages 4

Markdown input (flowing layout, not fixed .page boxes):

python scripts/render_pdf.py notes.md -o notes.pdf --page-size Letter

To preview Markdown as HTML first:

python scripts/md_to_html.py notes.md -o notes.html

Useful flags:

Flag What it does
-o / --output Output PDF path (required)
--page-size A4 or Letter Paper size. Omit it to use the document's own @page size (A4 if it declares none).
--landscape Print in landscape. A document can also declare @page { size: A4 landscape; } itself, as the certificate does.
--png-dir DIR Write one PNG per PDF page into DIR
--expect-pages N Exit with status 1 if the page count is not N
--scale Chromium print scale (default 1.0)

The script prints the page count, paper size, and file size, and writes warnings to
stderr when a .page box overflows, content runs into a .page-footer or .foot
band, or a font or image fails to load. Decorative art that should bleed off the
page can be marked aria-hidden="true" and is skipped by those checks.

Notes on paper size and orientation:

  • Documents built from fixed-size .page boxes (the flyer, certificate, and template)
    already carry their own dimensions. Pass --page-size or --landscape only when the
    CSS is written to follow it, as templates/document.html is through
    html[data-page-size] and html[data-orientation].
  • Flowing documents (Markdown, the data report) use @page margins, so they adapt to
    --page-size Letter and --landscape without changes.

How an agent should use this

Follow SKILL.md: plan the pages, copy the template, fill in the content,
render, inspect every page PNG, fix, then deliver. Check overflow, orphan
headings, split tables, fonts, page count, and contrast before you hand the
PDF over.

License

MIT. Copyright (c) 2026 Nayan Kunwar.

Reviews (0)

No results found