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.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pakkanpdf-0.1.1.tar.gz
  • Upload date:
  • Size: 7.0 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.1.tar.gz
Algorithm Hash digest
SHA256 d56a56057826b1221b2b92a0230ba825db91487efcd21c4c8df4c85e918f449a
MD5 d4454f5eca409d5698b5ad01359fcd3c
BLAKE2b-256 02ce28f1dfd259fb72fa516777e8b0572caf83c1b9951fe167c26ce6bb19b870

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pakkanpdf-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f015285625deb7e0edd5ae424a583a53f4488aff25e18a7d12df2c70162c4b4f
MD5 1de3cff3abeb181f57cc43fc90c7dbd1
BLAKE2b-256 a5da7ed718d881d399c03a1f56143cfd423a90dbd39a55fec373cc934517af52

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