Package: hotpdf
hotpdfThis project was started as an internal project @Prestatechto parse PDF files in a fast and memory-efficient way to overcome the difficulties we were having while parsing big PDF files using libraries such aspdfquery[Comparison].hotpdf is a wrapper aroundpdfminer.sixfocusing on text extraction and text search operations on PDFs.hotpdf can be used to find and extract text from PDFs.
Pleaseread the docsto understand how the library can help you!InstallationThe latest version of hotpdf can be installed directly fromPyPIwith pip.pipinstallhotpdfLocal SetupFirst install the dependencies required by hotpdfpython3-mpipinstall-e.ContributingYou should install thepre-commithooks withpre-commit install. This will run the linter, mypy, and ruff formatting before each commit.Rembember to runpip install -e '.[dev]'to install the extra dependencies for development.For more examples of how to run the full test suite please refer to theCI workflow.We strive to keep the test coverage at 100% (but can't due to certain reasons - e.g., test file not available): if you want your contributions accepted please write tests for them :DSome examples of running tests locally:python3-mpipinstall-e'.[dev]'# install extra deps for testingpython3-mpytest-n=autotests/# run the test suite# run tests with coveragepython3-mpytest--cov-fail-under=96-n=auto--cov=hotpdf--cov-reportterm-missingDocumentationWe usesphinxfor generating our docs and host them onreadthedocsPlease update and add documentation if required, with your contributions.Update the.rstfiles, rebuild them, and commit them along with your PRs.cddocs
makeclean
makehtmlThis will generate the necessary documentation files. Once merged tomainthe docs will be updated automatically.UsageTo view more detailed usage information, pleaseread the docsBasic usage is as follows:fromhotpdfimportHotPdfpdf_file_path="test.pdf"# Load pdf file into memoryhotpdf_document=HotPdf(pdf_file_path)# Alternatively, you can also pass an opened pdf stream to be loadedwithopen(pdf_file_path,"rb")asf:hotpdf_document_2=HotPdf(f)# You can also merge multiple HotPdf objects to get one single HotPdf objectmerged_hotpdf_object=HotPdf.merge_multiple(hotpdfs=[hotpdf1,hotpdf2])# Get number of pagesprint(len(hotpdf_document.pages))# Find texttext_occurences=hotpdf_document.find_text("foo")# Find text and its full spantext_occurences_full_span=hotpdf_document.find_text("foo",take_span=True)# Extract text in regiontext_in_bbox=hotpdf_document.extract_text(x0=0,y0=0,x1=100,y1=10,page=0,)# Extract spans in regionspans_in_bbox=hotpdf_document.extract_spans(x0=0,y0=0,x1=100,y1=10,page=0,)# Extract spans text in regionspans_text_in_bbox=hotpdf_document.extract_spans_text(x0=0,y0=0,x1=100,y1=10,page=0,)# Extract full page textfull_page_text=hotpdf_document.extract_page_text(page=0)Known Issues(cid:x) characters in text - Some pdfs when extracted, some symbols like€might not be properly decoded, and instead be extracted as(cid:128).This is a problem with thepdfminer.sixlibrary. We have fixed it from our side on ourfork, and you can install it using pip. Until we are able to merge it to pdfminer.six repo and it gets released, we recommend that you install our fork with the fixes manually.pipinstall--no-cache-dirgit+https://github.com/weareprestatech/pdfminer.six.git@20240222#egg=pdfminer-sixLicenseThis project is licensed under the terms of the MIT license.with ❤️ from the team @Prestatech GmbH