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> [<folder> ...] [options]

Arguments

Argument Description
folder One or more folder paths 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 multiple folders into one PDF:

folder2pdf ./backend ./frontend -o 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.2.tar.gz (17.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.2-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for folder2pdf-0.1.2.tar.gz
Algorithm Hash digest
SHA256 7c2893a36293d4f8d1092ad1f391e1b30bd2d7ebcf971d68e0975a43fce75b3f
MD5 c8268616fcb0e6bdb2ff69ec0c2f2369
BLAKE2b-256 fc0345ebb778e57dc8383a802b78fc1e5376f5a93e2ed989812f64ec14e31fe3

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for folder2pdf-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cf0a5aa078dfd9d30bb5b4b4555a9a5cf989e95fc5697ea846dc7d1dab4df6de
MD5 f30e70ff706e0228586f9d424da6cfd0
BLAKE2b-256 ce27f7824e12dfe3d0a6cafac4c5fae119948cc001dc21f8652ec35d166edd68

See more details on using hashes here.

Provenance

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