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. Processing runs in parallel on multiple cores
- 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
Using artefacts on Github Releases
Navigate to the latest release
Run the correct installer script for your system, or just download the correct binary directly
Build from repository source
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
Decoding
Generated PDFs can be decoded - recreating the original source tree which they were generated from