Skip to main content

Generate a PDF from a folder's contents (text files and images)

Project description

folder2pdf

Convert a folder's contents (and its sub-folders) into a single PDF document.
Text and source-code files are included as readable content; image files are embedded with captions.
The output is useful for AI ingestion tools like NotebookLLM.


Installation

pip install folder2pdf

Usage

folder2pdf <folder> [options]

Arguments

Argument Description
folder Path to the folder to convert.

Options

Option Description
-o, --output OUTPUT Destination PDF file path (default: output.pdf).
--no-images Do not embed image files in the PDF.
-e, --extensions EXT [EXT ...] Whitelist of file extensions to include, e.g. .py .md .txt. When omitted, built-in defaults are used.
-b, --blacklist PATTERN [PATTERN ...] Glob patterns (gitignore-style) for files or directories to exclude, e.g. tests/ *.log secret.txt.
--no-gitignore Do not read or apply the .gitignore file found in the target folder.

Examples

Convert a folder to PDF:

folder2pdf ./my-project -o my-project.pdf

Convert without images:

folder2pdf ./my-project -o my-project.pdf --no-images

Only include Python and Markdown files:

folder2pdf ./my-project -o my-project.pdf -e .py .md

Exclude test files and log files:

folder2pdf ./my-project -o my-project.pdf -b "tests/" "*.log"

Ignore .gitignore rules:

folder2pdf ./my-project -o my-project.pdf --no-gitignore

What gets included

Text / source-code files (default extensions):

.txt .md .rst .csv .tsv .json .xml .yaml .yml .toml
.ini .cfg .conf .env .log .py .js .ts .jsx .tsx
.html .htm .css .scss .java .c .cpp .h .hpp .cs
.go .rs .rb .php .sh .bash .zsh .ps1 .bat .sql and more.

Image files (embedded with captions):

.png .jpg .jpeg .gif .bmp .webp .tiff

Skipped automatically:

  • Hidden files and directories (names starting with .)
  • Files matched by the .gitignore in the target folder (requires pathspec)
  • Files matched by the --blacklist patterns
  • Binary files without a recognised extension

Project Summary (cover page)

The generated PDF cover page includes a Project Summary section with:

  • Total Files Processed – number of files included
  • Total Lines of Code – combined line count across all text files
  • Image Files – number of image files embedded
  • Lines by Extension – per-extension line counts, sorted by descending count

Programmatic API

from folder2pdf.converter import convert

pdf_path = convert(
    folder="./my-project",
    output="my-project.pdf",
    include_images=True,
    extensions=None,       # None = use built-in defaults
    blacklist=["tests/", "*.log"],  # optional exclusion patterns
    use_gitignore=True,    # read & apply .gitignore in the folder
)
print(f"PDF saved to {pdf_path}")

Dependencies

  • fpdf2 — PDF generation
  • Pillow — image processing
  • pathspec — gitignore-style pattern matching

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

folder2pdf-0.1.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

folder2pdf-0.1.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file folder2pdf-0.1.0.tar.gz.

File metadata

  • Download URL: folder2pdf-0.1.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for folder2pdf-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c146e30941ceea3b3a6d493637bf0d2aa9c9e6b926b4fde27c4e012e9a56fb5d
MD5 b4d72229c849682ed4761d56130f9bd8
BLAKE2b-256 5e104308d12dfd1c0c6f4ddcfe7515546915966cd3325ffd1fa195bd4f6a72fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for folder2pdf-0.1.0.tar.gz:

Publisher: publish.yml on hugotacito/folder2pdf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file folder2pdf-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: folder2pdf-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for folder2pdf-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e5aca0e2c0fc295d489cc6d5de1229b261ee9ed42b9624f7a17f16b210632263
MD5 3a10da027d9d7a9b36191066a15717d5
BLAKE2b-256 baa93ce3eb630276eca53555bc3938672ca870462b7d59166bb7ccbbd093c12d

See more details on using hashes here.

Provenance

The following attestation bundles were made for folder2pdf-0.1.0-py3-none-any.whl:

Publisher: publish.yml on hugotacito/folder2pdf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page