Skip to main content

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


Download files

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

Source Distribution

pdify-0.1.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

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

pdify-0.1.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

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

Hashes for pdify-0.1.0.tar.gz
Algorithm Hash digest
SHA256 34f35bd70db686f9fa5f7ca3f449d0c99caef977a5967571a0c0633fb1e2ca51
MD5 94ba50959ee8ed6fac0b0b996d9d8f5c
BLAKE2b-256 36869ce98d007aa8d7f007e07350eaa4d5957c06124f97a0870ebfd800c121f0

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on momos22251/PDiFy

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

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

Hashes for pdify-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3dc22880a96d4e44ade082ea50b9e9f7ca7407a0555a5040e2b9fde0e2b978c8
MD5 7fb0976c7333abbb5514134465fde8c5
BLAKE2b-256 2ba076801f6d45d3272f7c1b951402175c69ec351ac9612d53f656e2a0e6836c

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on momos22251/PDiFy

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