Skip to main content

pdf 内の text や image へのアクセスをコンテキストマネージャーを使ってシンプルに行える

Project description

pakkan-pdf

PDF 内の text や image へのアクセスをコンテキストマネージャーを使ってシンプルに行える。 pdfminer/pdfminer.six の Wrapper ライブラリです。

install

pip install pakkanpdf

使い方

  • PdfExtractor の pdf_path に pdf のパスを与え、work_dir に存在するディレクトリを指定する
    • work_dir に image を書き出すための一時ディレクトリが作成さえる
  • extractor.text を使うと、PDF の text を取得できる
  • extractor.image_file_paths を使うと、PDF の image (file path) を取得できる
from pakkanpdf import PdfExtractor

def test_sample():
    with PdfExtractor(pdf_path="data/example.pdf", work_dir="demo_work_dir") as extractor:
        assert "これはサンプルのPDFです" in extractor.text
        assert extractor.image_file_paths == ["demo_work_dir/work_images/X8.jpg"]

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

pakkanpdf-0.1.2.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

pakkanpdf-0.1.2-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file pakkanpdf-0.1.2.tar.gz.

File metadata

  • Download URL: pakkanpdf-0.1.2.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.12 Darwin/20.6.0

File hashes

Hashes for pakkanpdf-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e6bf5e8c5435faaeef4a22ff0a2d7fd73bcbb0fd9094f42cd92b601532feb5a5
MD5 95114ad0e302c57bbe840927d91fa3ac
BLAKE2b-256 7979b5570ade4b3e2ff3bd7cf4b180ef396c7975dcb891ff8b5ab73278ebee2e

See more details on using hashes here.

File details

Details for the file pakkanpdf-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pakkanpdf-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.12 Darwin/20.6.0

File hashes

Hashes for pakkanpdf-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 af08be12cc19a1da89ee4a079e8a058b7245a9a21c94f3034d672971aeefcb27
MD5 16780af5824baf5fa26215777744102c
BLAKE2b-256 edec5e1664762090e858bd0877bae90427ad4a8bc0fbec80eeae2cdf94aa3ae4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page