Skip to main content

Pyntagma is a Python library for creating and managing complex data structures with ease. Its name is derived from the Greek word 'Syntagma', meaning 'composition', symbolizing that this package fits for semi-structured documents

Project description

Pyntagma

Coverage Status Python Version License

Pyntagma is a Python library for creating and managing complex data extraction pipelines with ease. Its name is derived from the Greek word 'Syntagma', meaning 'composition', symbolizing that this package fits for semi-structured documents.

Features

  • PDF Document Processing: Extract and analyze text, words, and lines from PDF documents
  • Multi-file Document Support: Handle documents that span multiple PDF files
  • Precise Positioning: Track exact coordinates and positions of text elements
  • Type-safe Design: Built with Pydantic models for robust data validation
  • Silent PDF Processing: Suppresses verbose logging during PDF operations
  • Flexible Cropping: Extract specific regions from PDF pages

Installation

Install Pyntagma using:

pip install pyntagma

Quick Start

Basic Document Processing

from pyntagma import Document
from pathlib import Path

# Create a document from one or more PDF files
doc = Document(files=[
    Path("document-part1.pdf"),
    Path("document-part2.pdf")
])

# Access pages
print(f"Total pages: {len(doc.pages)}")

# Get the first page
page = doc.pages[0]
print(f"Page dimensions: {page.width} x {page.height}")

# Extract words and lines
words = page.words
lines = page.lines

print(f"Found {len(words)} words and {len(lines)} lines")

Working with Text Elements

# Access word properties
for word in page.words[:5]:  # First 5 words
    print(f"'{word.text}' at position ({word.x0}, {word.top})")
    print(f"Word dimensions: {word.x1 - word.x0} x {word.bottom - word.top}")

# Access line properties
for line in page.lines[:3]:  # First 3 lines
    print(f"Line: '{line.text}'")
    print(f"Line words: {len(line.words)}")

Position-based Operations

from pyntagma import Position, HorizontalCoordinate, VerticalCoordinate

# Create custom positions
position = Position(
    x0=HorizontalCoordinate(page=page, value=100),
    x1=HorizontalCoordinate(page=page, value=200),
    top=VerticalCoordinate(page=page, value=50),
    bottom=VerticalCoordinate(page=page, value=80)
)

# Check if one position contains another
word_position = page.words[0].position
if position.contains(word_position):
    print("Word is within the specified region")

PDF Cropping

from pyntagma import Crop

# Define a crop region
crop = Crop(
    path=Path("document.pdf"),
    page_number=0,
    x0=100.0,
    x1=400.0,
    top=50.0,
    bottom=200.0,
    padding=10,
    resolution=300
)

# Use the crop for further processing
print(f"Crop region: {crop}")

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

pyntagma-0.0.3.tar.gz (34.9 MB view details)

Uploaded Source

Built Distribution

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

pyntagma-0.0.3-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file pyntagma-0.0.3.tar.gz.

File metadata

  • Download URL: pyntagma-0.0.3.tar.gz
  • Upload date:
  • Size: 34.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.16

File hashes

Hashes for pyntagma-0.0.3.tar.gz
Algorithm Hash digest
SHA256 3a55a071e69b6086496d1631d6f17e187f4c58cfac4992e4b367dca01c3dc527
MD5 6ac4dbfa4c12bb150378b6aed7fbca0c
BLAKE2b-256 29ee9224da05dc31f43f9dcdffc423c1d84ae307f70ac2a101a7f03f46026457

See more details on using hashes here.

File details

Details for the file pyntagma-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pyntagma-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.16

File hashes

Hashes for pyntagma-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b447f09e1a04de8d646feb2fef53f48958d70e0c2de0e4f1b3cff4767fa583c0
MD5 2539473772c00a161a199369f73dce8f
BLAKE2b-256 458f0f56be49f1384758ff13433401f2bb006f90cb79a447a632c8eb735db627

See more details on using hashes here.

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