| Crates.io | code-to-pdf |
| lib.rs | code-to-pdf |
| version | 0.2.2 |
| created_at | 2025-03-24 23:15:26.384723+00 |
| updated_at | 2025-07-13 14:13:58.980972+00 |
| description | Generates a syntax-highlighted PDF of your source code |
| homepage | |
| repository | https://github.com/Tommypop2/code-to-pdf |
| max_upload_size | |
| id | 1604530 |
| size | 416,735 |
Converts a folder of source code to a fully syntax-highlighted PDF
.ignore and .gitignore (uses ignore)cargo install code-to-pdf
cargo binstallInstalls a pre-built binary if it is available for your system
cargo binstall code-to-pdf
Navigate to the latest release
Run the correct installer script for your system, or just download the correct binary directly
git clone https://github.com/Tommypop2/code-to-pdf
cargo install --path ./code-to-pdf
c2pdf .
This walks the current folder and generates a syntax-highlighted PDF of all files in that folder
c2pdf . --exclude pnpm-lock.yaml,*.lock
c2pdf . --out custom_name.pdf
Supports loading fonts from a path or the system fonts
# From a path
c2pdf . --font fonts/Helvetica.ttf
# From system fonts
c2pdf . --font "Arial"
c2pdf . --font-size 12.5 # 12.0 by default
c2pdf . --margin-top 20 --margin-bottom 5 --margin-left 10 --margin-right 10 # (these are the defaults)
This is text that is added to every page
c2pdf . --page-text "Hello\nWorld" # (use `\n` to indicate a newline)
Generated PDFs can be decoded - recreating the original source tree which they were generated from
dc2pdf ./generated_pdf.pdf --out-dir ./generated # Default out-dir is `./generated`