https://github.com/ryuapp/md2pdf
A simple CLI tool for converting markdown to PDF.
https://github.com/ryuapp/md2pdf
cli deno markdown markdown-to-pdf
Last synced: 8 months ago
JSON representation
A simple CLI tool for converting markdown to PDF.
- Host: GitHub
- URL: https://github.com/ryuapp/md2pdf
- Owner: ryuapp
- License: mit
- Created: 2024-08-14T05:18:47.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-01-20T17:43:03.000Z (over 1 year ago)
- Last Synced: 2025-03-15T08:33:44.427Z (about 1 year ago)
- Topics: cli, deno, markdown, markdown-to-pdf
- Language: TypeScript
- Homepage: https://jsr.io/@ryu/md2pdf
- Size: 44.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# md2pdf
[](https://jsr.io/@ryu/md2pdf)
A simple CLI tool for converting markdown to PDF.\
It uses `md4w` to convert markdown to HTML and `playwright-core` (headless Chrome) to further convert the HTML to PDF. It also uses `shiki` for code highlighting.
## Installation
To run it, you need to have [Google Chrome](https://www.google.com/chrome/) installed separately from the CLI.
```sh
deno install -grA jsr:@ryu/md2pdf/cli
```
Note: If you want to update the CLI, please reinstall with `-f` flag.
## Usage
```sh
md2pdf: A simple CLI tool for converting markdown to PDF.
Usage: md2pdf [OPTION]... [FILE]...
Options:
-w, --watch Watch for file changes.
-h, --help Print help.
-v, --version Print version.
--stylesheet Set CSS file path used for rendering.
```
The pdf is generated into the same directory as the markdown file and uses the same filename (with `.pdf` extension):
```sh
md2pdf file.md
```
Convert multiple markdown files:
```sh
md2pdf file1.md file2.md file3.md
```
### Watch mode
Watch for file changes and automatically regenerate PDF when the markdown file is modified:
```sh
md2pdf --watch file.md
```
This is useful for continuous development where you want to see PDF updates in real-time as you edit your markdown.
### `stdin` / `stdout` Support
md2pdf supports reading from `stdin` and writing to `stdout`.\
You can pipe markdown content directly to md2pdf, making it easy to integrate with other CLI tools:
```sh
# Convert piped input to PDF
cat file.md | md2pdf > path/to/output.pdf
# Use with curl to convert remote markdown
curl -s https://raw.githubusercontent.com/ryuapp/md2pdf/main/README.md | md2pdf > README.pdf
```
## Front matter (Experimental)
We can specify CSS file used in the front matter of markdown.
```md
---
stylesheet: ./github.css
---
# Hello World
```
## Related
- [md-to-pdf](https://github.com/simonhaenisch/md-to-pdf) - Markdown to PDF CLI
for Node.js.