pdf 内の text や image へのアクセスをコンテキストマネージャーを使ってシンプルに行える
Project description
pakkan-pdf
PDF 内の text や image へのアクセスをコンテキストマネージャーを使ってシンプルに行える。 pdfminer/pdfminer.six の Wrapper ライブラリです。
install
pip install pakkan-pdf
使い方
- 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.0.tar.gz
(7.0 kB
view details)
Built Distribution
File details
Details for the file pakkanpdf-0.1.0.tar.gz
.
File metadata
- Download URL: pakkanpdf-0.1.0.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5c8e079bf988822ee788e9ff3469e88bce60e2825e55a938a0ac1cc22b8a035 |
|
MD5 | 4f10e31cdc2168c8a06637eeacff648e |
|
BLAKE2b-256 | 5a308df60f13dceea69b8e21e22705abb1b70172a4098b9867d40ca22703502d |
File details
Details for the file pakkanpdf-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: pakkanpdf-0.1.0-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 186d535ccee178c976d68dbd13e8a616da769e0b40a2d7190f5e737480ed8459 |
|
MD5 | ac5a8c7147620c2aadcfbe8ad8f02697 |
|
BLAKE2b-256 | bfcb5d350f50010f3718abd51502c1e625d645386df28312a8e06aa936f89294 |