pypdf-lib
A (maybe) Better PDF Parsing for Python focused on textual extraction. WIP.
This library is a Python Wrapper built around PdfAct, which is built using Java.
Pre-requisites
Java
# Linux
apt-get update && apt-get install -y default-jre # openjdk-8-jre-headless / openjdk-11-jdk / openjdk-11-jre-headless
# Mac
brew install java
# Windows
# idk
Installation
!pip install --upgrade git+https://github.com/trisongz/pypdf-lib.git
!pip install --upgrade pypdf-lib
Usage
from pypdf import PyPDF
from fileio import File
base_dir = '/content/output'
File.mkdirs(base_dir)
# Using a remap function expects the file extension to be mapped properly - i.e. if 'txt' is selected, .txt file extension should be returned.
def remap_fnames(fname):
fname = File.base(fname).replace('- ', '').replace(' ', '_').strip().replace('.pdf', '.json')
return File.join(base_dir, fname)
converter = PyPDF(input_dir='/content/inputs', output_dir='/content/output', units=['paragraphs', 'blocks'], visualize=True)
# remap_funct is optional.
for res in converter.extract(remap_funct=remap_fnames):
print(res)
# > /content/output/your_json_file_1.json
converter.extracted
'''
{'/content/inputs/input_1.pdf': '/content/output/your_json_file_1.json',
'/content/inputs/input_2.pdf': '/content/output/your_json_file_2.json',
'/content/inputs/input_3.pdf': '/content/output/your_json_file_3.json',
'params': {'exclude_roles': None,
'format': 'json',
'include_roles': ['title',
'body',
'appendix',
'keywords',
'heading',
'general_terms',
'toc',
'caption',
'table',
'other',
'categories',
'keywords',
'page_header'],
'units': ['paragraphs', 'blocks'],
'visualize': True,
'with_control_characters': False}}
'''
Release files for pypdf-lib 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pypdf-lib-0.0.3.tar.gz | 5.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pypdf_lib-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.9 kB
Release files / pypdf-lib-0.0.3.tar.gz
| Download URL | pypdf-lib-0.0.3.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b7717df0955904ab549c84fe6fb2c9f4dc8006862b37540402c6c5455ff4b098
|
|
BLAKE2b-256 checksum How to use checksums |
ed76b4cee7a204dce4f8b712b954bcf933f1229273ede59a80db9a4c0b4d8631
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2
|
Release files / pypdf_lib-0.0.3-py3-none-any.whl
| Download URL | pypdf_lib-0.0.3-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ad08a84b21e4940151b0dd6da58488515f9e8cba5eeec85c10ca8e3596122446
|
|
BLAKE2b-256 checksum How to use checksums |
45b4fd6c6c11e3e45900a126ca31ab56b682062e70f2b34c9fd515888b7c215a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2
|