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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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