codepdf
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

codepdf 📄✨

npm version

Convert code repositories or directories into beautifully formatted PDF documents with syntax highlighting, line numbers, and a table of contents. Ideal for code reviews, documentation, or offline reading.

Description

codepdf is a command-line tool that scans a given directory, identifies code files, applies syntax highlighting, and generates a clean, readable PDF document. It's designed to help document codebases, share code snippets, or create offline references.

Features

  • Automatic File Discovery: Scans directories recursively, respecting .gitignore rules and common exclusion patterns (like node_modules, .git).
  • Language Detection: Automatically detects the programming language for syntax highlighting.
  • Syntax Highlighting: Uses highlight.js to provide highlighting for numerous languages.
  • Theming: Supports customizable themes (e.g., 'light', 'dark') for code appearance.
  • PDF Generation: Creates well-structured PDFs using pdfkit.
  • Customization: Offers options for:
    • Output filename.
    • PDF Title.
    • Code font size.
    • Line numbers (optional).
    • Paper size (A4, Letter, custom).
    • Cover page.
    • Table of Contents (for multiple files).
    • Headers with file paths and footers with page numbers.

Installation

npm install -g codepdf

Example Usage

Once installed, you can run the tool from your terminal. Here's a basic example:

codepdf ./path/to/your/code-project -o project-snapshot.pdf

Package Sidebar

Install

npm i codepdf

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

96.2 kB

Total Files

11

Last publish

Collaborators

  • jacobli99