pdf-decomposer
For the convenience of analysis, sometimes it is necessary to extract the content from PDF document. This project uses local tools to extract images, tables, and text from PDF file.
Install
Install appropriate version of PaddlePaddle and PyTorch. Here is an example using CUDA 11.8.
sudo apt install tesseract-ocr
sudo apt install tesseract-ocr-chi-sim
pip install paddlepaddle-gpu==2.5.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install torch torchvision torchaudio -i https://download.pytorch.org/whl/cu118
pip install 'git+https://github.com/facebookresearch/detectron2.git'
Install from source code.
pip install .
or
pip install pdf-decomposer
If you are unable to download the layout-parser model automatically, please download it yourself based on the link provided in the error message, and then specify the local config_path and model_path.
Solution based on PaddleOCR
Use layout analysis and table structure model in PaddleOCR ppstructure to recognize layout elements and reconstruct tables. Then use PyMuPDF to parse text and organize paragraph.
import pdf_decomposer
decomposer = pdf_decomposer.PaddlePDFDecomposer()
decomposer(example_file, output_dir)
Alternative local solution
Compared to the Paddle solution, use layout-parser to conduct layout analysis, and then search adaptive thresholds with genetic algorithm to reconstruct tables.
import pdf_decomposer
decomposer = pdf_decomposer.OpenPDFDecomposer()
decomposer(example_file, output_dir)
Solution based on Adobe service
Call Acrobat PDF Services API to extract various elements from PDF files. Please apply for the API key here. Make sure to set api key before running.
export ADOBE_CLIENT_ID=<YOUR CLIENT ID>
export ADOBE_CLIENT_SECRET=<YOUR CLIENT SECRET>
import pdf_decomposer
decomposer = pdf_decomposer.AdobePDFDecomposer()
decomposer(example_file, output_dir)
Metadata
Release files for pdf-decomposer 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pdf_decomposer-0.2.1.tar.gz | 22.9 kB | Without provenance | Details for pdf_decomposer-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pdf_decomposer-0.2.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for pdf_decomposer-0.2.1-py2.py3-none-any.whl |
Total release size: 47.6 kB
Release files / pdf_decomposer-0.2.1.tar.gz
| Download URL | pdf_decomposer-0.2.1.tar.gz |
|---|---|
| Size | 22.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4a707cf8c0a360cf066915de8a682ba3f0803b7a86b4bc9f4dd8dc03f34debcd
|
|
BLAKE2b-256 checksum How to use checksums |
49d5a28f579275d287d7fda388f5fec3a7a6a4c0a3220fe4f686c6c22a840c96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / pdf_decomposer-0.2.1-py2.py3-none-any.whl
| Download URL | pdf_decomposer-0.2.1-py2.py3-none-any.whl |
|---|---|
| Size | 24.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
a2f368d25577aa219c841545e3cf633ac418b23e6a75d983cdbf653d0de4f89f
|
|
BLAKE2b-256 checksum How to use checksums |
98e06a3998f0e4e9bcf88e4b0ec0967c6b762d1498fa00dd836c9109159c8839
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Security for pdf-decomposer 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.