Extract text layout and cohesive figures from PDF files
Project description
pdify
pdify is a Python package to extract clean text layout structures and cohesive figures from PDF documents (like research papers or reports), preventing fragmented crops or nested image duplication.
Features
- Cohesive Figure Extraction: Groups overlapping/nested image elements into single cohesive crops.
- Layout Reconstruction: Reconstructs paragraphs and column spans in correct visual reading order.
- Hyphenation & Ligatures: Automatically resolves word hyphens and common ligatures.
- Parallel Processing: Uses multi-processing to extract content concurrently.
Installation
You can install pdify directly from PyPI:
pip install pdify
Note: Depending on your system and PDF files, you may also need ghostscript if rendering certain vector formats.
Usage
Command Line Interface (CLI)
Once installed, you can use the pdify CLI directly:
pdify --input path/to/document.pdf
Run pdify --help to view all available CLI options.
Python API
You can also import and use pdify programmatically in your own Python projects:
import pdfplumber
from pdify import extract_text_and_words_with_layout, get_cohesive_figure_boxes
# Open a PDF file
with pdfplumber.open("document.pdf") as pdf:
# Process the first page
page = pdf.pages[0]
# 1. Get cohesive figure boxes (automatically merging nested crops)
figure_boxes = get_cohesive_figure_boxes(page)
# 2. Extract text layout while ignoring headers/footers and text within figure boxes
text_content, words = extract_text_and_words_with_layout(
page,
remove_headers_footers=True,
exclude_figure_text=True,
figure_boxes=figure_boxes
)
print(text_content)
Output Structure
Outputs are saved to extracted_content/<pdf_name>/ by default:
text/: Clean page text (page_N_text.txt) and word coordinate metadata (page_N_text_metadata.json).images/: High-resolution cohesive figure crops (page_N_figure_M.png) and bounding box metadata (page_N_figure_M_metadata.json).
License
MIT License. See LICENSE for details.
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 pdify-0.1.0.tar.gz.
File metadata
- Download URL: pdify-0.1.0.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34f35bd70db686f9fa5f7ca3f449d0c99caef977a5967571a0c0633fb1e2ca51
|
|
| MD5 |
94ba50959ee8ed6fac0b0b996d9d8f5c
|
|
| BLAKE2b-256 |
36869ce98d007aa8d7f007e07350eaa4d5957c06124f97a0870ebfd800c121f0
|
Provenance
The following attestation bundles were made for pdify-0.1.0.tar.gz:
Publisher:
publish.yml on momos22251/PDiFy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdify-0.1.0.tar.gz -
Subject digest:
34f35bd70db686f9fa5f7ca3f449d0c99caef977a5967571a0c0633fb1e2ca51 - Sigstore transparency entry: 1630280819
- Sigstore integration time:
-
Permalink:
momos22251/PDiFy@0643a1c1537b04c0315873599404450559d80528 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/momos22251
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0643a1c1537b04c0315873599404450559d80528 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pdify-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pdify-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3dc22880a96d4e44ade082ea50b9e9f7ca7407a0555a5040e2b9fde0e2b978c8
|
|
| MD5 |
7fb0976c7333abbb5514134465fde8c5
|
|
| BLAKE2b-256 |
2ba076801f6d45d3272f7c1b951402175c69ec351ac9612d53f656e2a0e6836c
|
Provenance
The following attestation bundles were made for pdify-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on momos22251/PDiFy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdify-0.1.0-py3-none-any.whl -
Subject digest:
3dc22880a96d4e44ade082ea50b9e9f7ca7407a0555a5040e2b9fde0e2b978c8 - Sigstore transparency entry: 1630280876
- Sigstore integration time:
-
Permalink:
momos22251/PDiFy@0643a1c1537b04c0315873599404450559d80528 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/momos22251
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0643a1c1537b04c0315873599404450559d80528 -
Trigger Event:
release
-
Statement type: