Your personal CLI butler.
cd alf/
npm install
npm linkConvert any HTML file to PDF with styles preserved and links clickable.
alf html2pdf --input resume.html --output resume.pdf| Option | Short | Description |
|---|---|---|
--input |
-i |
Input HTML file |
--output |
-o |
Output PDF file |
The underlying Playwright/Chromium waits for web fonts and JavaScript-rendered content (e.g. FontAwesome icons) to settle before printing. CSS @media print rules are honoured, and the PDF is tagged so hyperlinks remain clickable.
Convert a Markdown file (with YAML front matter) to PDF in one step.
alf md2pdf --md cv.md --pdf cv.pdf| Option | Short | Description |
|---|---|---|
--md |
-m |
Input Markdown file |
--pdf |
-p |
Output PDF file |
The YAML front matter declares CSS/JS assets and extra header tags:
---
title: "My Resume"
output:
html:
meta:
css: ["static/default.css", "static/font.css"]
js: ["js/default.js"]
header-includes: '<script src="https://kit.fontawesome.com/xxx.js" crossorigin="anonymous"></script>'
---CSS @import URLs (e.g. Google Fonts) are automatically downloaded and inlined as base64 data URIs, so the intermediate HTML is fully self-contained. Pandoc fenced Divs (::::: {#id .class}) are supported in the Markdown.
alf/
├── bin/
│ └── alf.mjs # CLI entry point
├── src/
│ ├── cli.mjs # Commander setup, command registration
│ ├── commands/
│ │ ├── html2pdf.mjs # alf html2pdf
│ │ └── md2pdf.mjs # alf md2pdf
│ └── lib/
│ ├── browser.mjs # Playwright PDF rendering
│ └── markdown.mjs # Markdown parsing & CSS inlining
└── package.json
-
Create
src/commands/<name>.mjsexporting a function that returns aCommand:import { Command } from 'commander'; export function myCommand() { return new Command('mycmd') .description('Does something useful') .action(() => { /* ... */ }); }
-
Register it in
src/cli.mjs:import { myCommand } from './commands/mycmd.mjs'; program.addCommand(myCommand());