pdf-decomposer


Namepdf-decomposer JSON
Version 0.2.1 PyPI version JSON
download
home_pagehttps://github.com/marswen/pdf-decomposer
SummaryExtract structured information from images, tables, and text in PDF document.
upload_time2023-12-29 07:55:23
maintainer
docs_urlNone
authormarswen
requires_python
licenseAGPL-3.0
keywords pdf layout table extraction
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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](https://acrobatservices.adobe.com/dc-integration-creation-app-cdn/main.html?api=pdf-extract-api#). 
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)
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/marswen/pdf-decomposer",
    "name": "pdf-decomposer",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "pdf,layout,table extraction",
    "author": "marswen",
    "author_email": "dongwen930910@foxmail.com",
    "download_url": "https://files.pythonhosted.org/packages/49/d5/a28f579275d287d7fda388f5fec3a7a6a4c0a3220fe4f686c6c22a840c96/pdf_decomposer-0.2.1.tar.gz",
    "platform": null,
    "description": "# pdf-decomposer\n\nFor the convenience of analysis, sometimes it is necessary to extract the content from PDF document. \nThis project uses local tools to extract images, tables, and text from PDF file.\n\n\n### Install\n\nInstall appropriate version of PaddlePaddle and PyTorch. Here is an example using CUDA 11.8.\n```\nsudo apt install tesseract-ocr\nsudo apt install tesseract-ocr-chi-sim\n\npip install paddlepaddle-gpu==2.5.2 -i https://pypi.tuna.tsinghua.edu.cn/simple\npip install torch torchvision torchaudio -i https://download.pytorch.org/whl/cu118\npip install 'git+https://github.com/facebookresearch/detectron2.git'\n```\n\nInstall from source code.\n```\npip install .\n```\nor\n```\npip install pdf-decomposer\n```\n\nIf 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.\n\n\n### Solution based on PaddleOCR\n\nUse layout analysis and table structure model in PaddleOCR ppstructure to recognize layout elements and reconstruct tables.\nThen use PyMuPDF to parse text and organize paragraph.\n\n```\nimport pdf_decomposer\n\ndecomposer = pdf_decomposer.PaddlePDFDecomposer()\ndecomposer(example_file, output_dir)\n```\n\n\n### Alternative local solution\n\nCompared to the Paddle solution, use layout-parser to conduct layout analysis,\nand then search adaptive thresholds with genetic algorithm to reconstruct tables.\n\n```\nimport pdf_decomposer\n\ndecomposer = pdf_decomposer.OpenPDFDecomposer()\ndecomposer(example_file, output_dir)\n```\n\n\n### Solution based on Adobe service\n\nCall Acrobat PDF Services API to extract various elements from PDF files. \nPlease apply for the API key [here](https://acrobatservices.adobe.com/dc-integration-creation-app-cdn/main.html?api=pdf-extract-api#). \nMake sure to set api key before running.\n\n```\nexport ADOBE_CLIENT_ID=<YOUR CLIENT ID>\nexport ADOBE_CLIENT_SECRET=<YOUR CLIENT SECRET>\n```\n\n```\nimport pdf_decomposer\n\ndecomposer = pdf_decomposer.AdobePDFDecomposer()\ndecomposer(example_file, output_dir)\n```\n\n",
    "bugtrack_url": null,
    "license": "AGPL-3.0",
    "summary": "Extract structured information from images, tables, and text in PDF document.",
    "version": "0.2.1",
    "project_urls": {
        "Homepage": "https://github.com/marswen/pdf-decomposer"
    },
    "split_keywords": [
        "pdf",
        "layout",
        "table extraction"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "98e06a3998f0e4e9bcf88e4b0ec0967c6b762d1498fa00dd836c9109159c8839",
                "md5": "b9e529010d9daaff324deb41e0747065",
                "sha256": "a2f368d25577aa219c841545e3cf633ac418b23e6a75d983cdbf653d0de4f89f"
            },
            "downloads": -1,
            "filename": "pdf_decomposer-0.2.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b9e529010d9daaff324deb41e0747065",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 24743,
            "upload_time": "2023-12-29T07:55:22",
            "upload_time_iso_8601": "2023-12-29T07:55:22.021422Z",
            "url": "https://files.pythonhosted.org/packages/98/e0/6a3998f0e4e9bcf88e4b0ec0967c6b762d1498fa00dd836c9109159c8839/pdf_decomposer-0.2.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "49d5a28f579275d287d7fda388f5fec3a7a6a4c0a3220fe4f686c6c22a840c96",
                "md5": "cc1c4293d0980009c766edadea5c4113",
                "sha256": "4a707cf8c0a360cf066915de8a682ba3f0803b7a86b4bc9f4dd8dc03f34debcd"
            },
            "downloads": -1,
            "filename": "pdf_decomposer-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "cc1c4293d0980009c766edadea5c4113",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 22868,
            "upload_time": "2023-12-29T07:55:23",
            "upload_time_iso_8601": "2023-12-29T07:55:23.128308Z",
            "url": "https://files.pythonhosted.org/packages/49/d5/a28f579275d287d7fda388f5fec3a7a6a4c0a3220fe4f686c6c22a840c96/pdf_decomposer-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-29 07:55:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "marswen",
    "github_project": "pdf-decomposer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pdf-decomposer"
}
        
Elapsed time: 0.16185s