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
.gitignorein the target folder (requirespathspec) - Files matched by the
--blacklistpatterns - 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c70f01b4df15916180e313074e5eede4599a467aff5ff6a3f6a35400d85a2cd8
|
|
| MD5 |
33400399693b6d0e75f26b635f95dfbf
|
|
| BLAKE2b-256 |
35dcf9c766b399aa18434953e250f830f168310d117adbcff424b563b633065f
|
Provenance
The following attestation bundles were made for folder2pdf-0.1.1.tar.gz:
Publisher:
publish.yml on hugotacito/folder2pdf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
folder2pdf-0.1.1.tar.gz -
Subject digest:
c70f01b4df15916180e313074e5eede4599a467aff5ff6a3f6a35400d85a2cd8 - Sigstore transparency entry: 1165584516
- Sigstore integration time:
-
Permalink:
hugotacito/folder2pdf@3cfb32d9d097974b270c38295ded0c6ccba587e0 -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/hugotacito
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3cfb32d9d097974b270c38295ded0c6ccba587e0 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
789b35b15ac9fdf6450cd334cdf4e37685caa560f0d84b3d5525564f3c861404
|
|
| MD5 |
fe6a10b3931765a829119c8fd42971bb
|
|
| BLAKE2b-256 |
9c88d24e815016bedfdabcbbf509472219e76e1a01ae9ccd8cefce7588de3173
|
Provenance
The following attestation bundles were made for folder2pdf-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on hugotacito/folder2pdf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
folder2pdf-0.1.1-py3-none-any.whl -
Subject digest:
789b35b15ac9fdf6450cd334cdf4e37685caa560f0d84b3d5525564f3c861404 - Sigstore transparency entry: 1165584622
- Sigstore integration time:
-
Permalink:
hugotacito/folder2pdf@3cfb32d9d097974b270c38295ded0c6ccba587e0 -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/hugotacito
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3cfb32d9d097974b270c38295ded0c6ccba587e0 -
Trigger Event:
release
-
Statement type: