Skip to main content

pdftxt

The goal of this project is to provide an api to extract text from specific regions of a pdf document/page and a cli to assist identifying the location of text within a document.

Installation

... pip install pdftxt

Basic Command Line Usage

Let's say we have a PDF file (PDF-DOC.pdf) that looks like this:

Source File Image

The pdftxt command:

... pdftxt PDF-DOC.pdf

Will output a visual layout of the pdf document's pages and text elements to an html page:

Output File Image

API Usage

from pathlib import Path
from pdftxt import api

filepath = 'tests/Word_PDF.pdf'

with api.PdfTxtContext(filepath) as pdf:

    for page in pdf:

        # To fetch text objects from specific region
        # of the page, first define the region:
        region = api.Region(400, 300, 512, 317)

        # Initialize layout parameters:
        params = api.PdfTxtParams()

        # Then analyze that area of the page for text objects:
        text = page.analyze(region, params)

        # Do whatever it is we need to do with the results:
        for txt in text:
            print(txt.text)

Release files for pdftxt 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pdftxt 0.3.2
File Size Uploaded
pdftxt-0.3.2.tar.gz 13.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pdftxt 0.3.2
File Interpreter ABI Platform
pdftxt-0.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 58.0 kB

Release files / pdftxt-0.3.2.tar.gz

Download URL pdftxt-0.3.2.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
768cbd8caa754493d58100bca3ee97bf423f14212e93164169549a83a358bf83
BLAKE2b-256 checksum
How to use checksums
921d4d6702d16e9db6994a4cacf9daba215093deb0d380c2cdf3e616e1b0c7d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.11 CPython/3.6.2 Darwin/17.7.0

Release files / pdftxt-0.3.2-py3-none-any.whl

Download URL pdftxt-0.3.2-py3-none-any.whl
Size 44.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d80ae0dc3a33b097d2ca7f51fb97db4451287cc75c49078c29544cce0d1f6bec
BLAKE2b-256 checksum
How to use checksums
9e2751efbdc795d4a83435da586cbe154946627ff879c99f616cd5487c93ce8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.11 CPython/3.6.2 Darwin/17.7.0

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page