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 hashes)
Built Distribution
Close
Hashes for pakkanpdf-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af08be12cc19a1da89ee4a079e8a058b7245a9a21c94f3034d672971aeefcb27 |
|
MD5 | 16780af5824baf5fa26215777744102c |
|
BLAKE2b-256 | edec5e1664762090e858bd0877bae90427ad4a8bc0fbec80eeae2cdf94aa3ae4 |