A powerful CLI tool for generating PDF documents from GitHub repositories with enhanced functionality.
git2pdf is a versatile command-line tool designed to transform GitHub repositories into well-formatted, visually engaging PDF files. This tool automates the process of cloning repositories and parsing code files, serving various use cases including:
- Code reviews and documentation
- Offline reference materials
- Teaching materials
- Technical documentation
- Code archiving
- Integration with AI systems
git2pdf can be installed using NPM:
npm install -g git2pdf
Or used directly with NPX:
npx git2pdf
git2pdf [repository] [options]
-l, --local
: Use a local repository-o, --output <file>
: Output file name (default: output.pdf)-d, --dir <directory>
: Output directory for individual PDFs (default: ./output)--line-numbers
: Add line numbers to code in PDF--highlighting
: Add syntax highlighting in PDF--page-numbers
: Add page numbers to PDF--remove-comments
: Remove comments from code--remove-empty
: Remove empty lines--split
: Generate one PDF per file--keep-repo
: Keep cloned repository after processing-h, --help
: Display help information-V, --version
: Display version number
Generate a PDF from a GitHub repository:
git2pdf https://github.com/user/repo
Generate a PDF with line numbers and syntax highlighting:
git2pdf https://github.com/user/repo --line-numbers --highlighting
Use a local repository:
git2pdf -l ./my-local-repo --output my-docs.pdf
Create separate PDFs for each file:
git2pdf https://github.com/user/repo --split --dir ./output
git2pdf automatically ignores certain file types and directories (e.g., .png
, .git
).
To customize the files and directories to ignore, you can add a git2pdf.ignore
file to the root of your repository:
{
"ignoredFiles": ["tsconfig.json", "dist", "node_modules"],
"ignoredExtensions": [".raw"]
}
- Node.js >= 18.0.0
- Git (for non-local repositories)
Contributions are welcome! Please feel free to submit a Pull Request.
This project is a fork of the original repo2pdf by BankkRoll, with enhanced CLI functionality and improvements.
This project is licensed under the MIT License - see the LICENSE file for details.