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.2.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.2-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyntagma-0.0.2.tar.gz
Algorithm Hash digest
SHA256 693ae5d54e2ed1b35a288a41ab52d30e5539653ef6c4b1f986a08dea3d4d486a
MD5 0a79743fec46627a3009cd814ad9b344
BLAKE2b-256 eb67b4e6af95259e14387f794b91ae28eda7bc4221e40a0b062dfaebd82f9278

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pyntagma-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 be776c7e107b84fd428f85669df067ef5430364bd185f4d181975780d77a1360
MD5 7d29d433826422eefa0ae5a30316c627
BLAKE2b-256 2aba0609114394f4aa187c011189baf2c6c3984329e27f9ada628b865fa7d281

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