An open API service indexing awesome lists of open source software.

https://github.com/hreikin/pdf-toolbox

Extract content from PDF's and convert or create new documents from the content in multiple output formats.
https://github.com/hreikin/pdf-toolbox

adobe document-conversion document-converter document-creation document-creator document-extraction image-extraction pandoc pymupdf pypandoc python python3 scrapy text-extraction

Last synced: 3 months ago
JSON representation

Extract content from PDF's and convert or create new documents from the content in multiple output formats.

Awesome Lists containing this project

README

        

# PDF Toolbox

[![Commits][commit-shield]][commit-url]
[![Contributors][contributors-shield]][contributors-url]
[![Issues][issues-shield]][issues-url]
[![License][license-shield]][license-url]

## About The Project

PDF Toolbox aims to be a PDF content extraction, conversion and creation
program. The goal is to extract content via various methods and store it in
a database for use in other document creation.



This should hopefully allow easier conversion to other formats and also let
you create new documents using any text, tables pictures, etc you may
already have available in other file formats.



All development work currently happens on the `development` branch and changes
are merged frequently into `main`. Once a solid base has been formed a 0.1
release will be created and merges from the `development` branch will only be
for security fixes, bug fixes and new versions.

Table of Contents



  1. About The Project



  2. Getting Started



  3. Roadmap

  4. Contributing

  5. License

  6. Contact


### Built With

* [Python3](https://www.python.org/)
* [PyMuPDF](https://github.com/pymupdf/PyMuPDF)
* [PyTesseract](https://github.com/madmaze/pytesseract)
* [Adobe PDF Extract API](https://developer.adobe.com/document-services/apis/pdf-extract/)

## Getting Started

To get a local copy up and running follow these simple steps.

### Prerequisites

* **Adobe**
* Place `Adobe PDF Extract API` credentials in root of repository. Credentials are available from [Adobe](https://developer.adobe.com/document-services/apis/pdf-extract/) with a 1000 credit/six month free trial.
* **Pillow/PIL**
* Install `Python Imaging Library` (or the `Pillow fork`) for your OS. Installation instructions available at the [Pillow](https://pillow.readthedocs.io/en/stable/installation.html) documentation.
* **TesseractOCR**
* Install `Tesseract OCR` for your OS. Installation instructions available at the [Tesseract OCR](https://github.com/tesseract-ocr/tesseract) github repository.
* **MuPDF**
* Install `MuPDF` for your OS. Installation instructions available at the [MuPDF](https://mupdf.com) website.

### Installation

1. Get a free API Key/Credentials at [Adobe](https://developer.adobe.com/document-services/apis/pdf-extract/).
2. Clone the repo
```sh
git clone https://github.com/hreikin/pdf-toolbox.git
```
3. Create and source a Python virtual environment.
```sh
python3 -m venv .venv
source .venv/bin/activate
```
4. Install requirements with `pip`
```sh
pip install -r requirements.txt
```

### Known Issues
On Linux (Windows/Mac untested) the file `.venv/lib64/python3.9/site-packages/ado
be/pdfservices/operation/internal/io/file_ref_impl.py` from `pdfservices-sdk`
inside the `venv` you create needs a few changes otherwise it might fail with a
false `cross-device link` error.

Add `import shutil` to the top of the file and on line 46 alter it to the
following to successfully save the JsonSchema/zip file it outputs. This does not
deal with deleting the temporary file as it only copies it however with it being
in temp it should be deleted on a reboot anyway so for now this hacky workaround
should be ok:

```python
shutil.copy(self._file_path, abs_path)
```

### Comparison Scores
The file `confidence.py` creates three text files for comparison to create a
rudimentary confidence check as one isn't provided by the API. The score is a
comparison between the API's extraction and other extraction techniques. Scores
are calculated using the `SequenceMatcher` class and `get_close_matches` method
from `difflib`.

A score of **0.6** for any of the calculated scores is considered a close match.
All scores are stored in a dictionary and a text file is created with the
results.

(back to top)

## Roadmap

See the [open issues](https://github.com/hreikin/pdf-toolbox/issues) for a full list of proposed features (and known issues).

- [ ] [Database](https://github.com/hreikin/pdf-toolbox/issues/2)
- [ ] [Extraction](https://github.com/hreikin/pdf-toolbox/issues/3)
- [x] [Comparison Score](https://github.com/hreikin/pdf-toolbox/issues/4)
- [ ] [Conversion](https://github.com/hreikin/pdf-toolbox/issues/5)
- [ ] [Creation](https://github.com/hreikin/pdf-toolbox/issues/6)
- [ ] [Merge & Combine](https://github.com/hreikin/pdf-toolbox/issues/7)
- [ ] [GUI](https://github.com/hreikin/pdf-toolbox/issues/11)

(back to top)

## Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

(back to top)

## License

Distributed under the MIT License. See `LICENSE.txt` for more information.

(back to top)

## Contact

Personal Website: [https://hreikin.co.uk](https://hreikin.co.uk)

Project Link: [https://github.com/hreikin/pdf-toolbox](https://github.com/hreikin/pdf-toolbox)

(back to top)

[contributors-shield]: https://img.shields.io/github/contributors/hreikin/pdf-toolbox.svg?style=for-the-badge
[contributors-url]: https://github.com/hreikin/pdf-toolbox/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/hreikin/pdf-toolbox.svg?style=for-the-badge
[forks-url]: https://github.com/hreikin/pdf-toolbox/network/members
[stars-shield]: https://img.shields.io/github/stars/hreikin/pdf-toolbox.svg?style=for-the-badge
[stars-url]: https://github.com/hreikin/pdf-toolbox/stargazers
[issues-shield]: https://img.shields.io/github/issues/hreikin/pdf-toolbox.svg?style=for-the-badge
[issues-url]: https://github.com/hreikin/pdf-toolbox/issues
[license-shield]: https://img.shields.io/github/license/hreikin/pdf-toolbox.svg?style=for-the-badge
[license-url]: https://github.com/hreikin/pdf-toolbox/blob/main/LICENSE.txt
[commit-shield]: https://img.shields.io/github/commit-activity/m/hreikin/pdf-toolbox?style=for-the-badge
[commit-url]: https://github.com/hreikin/pdf-toolbox/graphs/commit-activity