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.1.tar.gz (17.1 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.1-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: folder2pdf-0.1.1.tar.gz
  • Upload date:
  • Size: 17.1 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.1.tar.gz
Algorithm Hash digest
SHA256 c70f01b4df15916180e313074e5eede4599a467aff5ff6a3f6a35400d85a2cd8
MD5 33400399693b6d0e75f26b635f95dfbf
BLAKE2b-256 35dcf9c766b399aa18434953e250f830f168310d117adbcff424b563b633065f

See more details on using hashes here.

Provenance

The following attestation bundles were made for folder2pdf-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: folder2pdf-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.8 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 789b35b15ac9fdf6450cd334cdf4e37685caa560f0d84b3d5525564f3c861404
MD5 fe6a10b3931765a829119c8fd42971bb
BLAKE2b-256 9c88d24e815016bedfdabcbbf509472219e76e1a01ae9ccd8cefce7588de3173

See more details on using hashes here.

Provenance

The following attestation bundles were made for folder2pdf-0.1.1-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