code-to-pdf
Converts a folder of source code to a fully syntax-highlighted PDF
Features
- Syntax highlights code (uses syntect for highlighting and two-face for syntax definitions)
- Automatically handles line wrapping and page overflowing
- Fast
- Error-tolerant
- Configurable (custom file exclusions, output filename, fonts)
- Displays images
- Respects ignore globs in
.ignore
and.gitignore
(uses ignore)
Installation
From crates.io
Using cargo binstall
Installs a pre-built binary if it is available for your system
From this repository
Usage
Generating a PDF from a folder
This walks the current folder and generates a syntax-highlighted PDF of all files in that folder
Excluding paths
Custom output path
Setting the font
Supports loading fonts from a path or the system fonts
# From a path
# From system fonts
Setting font size
Setting margins
Setting custom page text
This is text that is added to every page