GithubHelp home page GithubHelp logo

convert_pdf_to_json's Introduction

Convert PDF to JSON

The Convert PDF to JSON repository contains functionality to convert PDF files to JSON files. You use the Python program and a bash automation to convert multiple PDF files. The Python program uses the PyPDF2 library.

With the 'Convert PDF to JSON' repository, you can define the root folder in the bash file. The bash automation efficiently iterates through all documents, executing the Python program to read the PDF files and convert them into JSON files by separating each page as an entry in a nested JSON array. This streamlined process ensures maximum productivity.

As a result of the conversion process, the PDF files are transformed into JSON files. These JSON files are structured as a JSON array, with each page of the original PDF file represented as an entry in the array.

{ 
  "file": "/path/to/pdf_file/file.pdf",
  "pdf_pages" : 
    [{"page":"1","content":"xxx"},
     {"page":"2","content":"yyy"}]
}
  • Clone the project
git clone https://github.com/thomassuedbroecker/convert_pdf_to_json.git
  • Create folders
mkdir pdf_input
mkdir pdf_export
  • Create a virtual Python environment
python3 -m venv .venv
source ./.venv/bin/activate
  • Install need Phython libraries.
python3 -m pip install PyPDF2
# python3 -m pip install python-docx
  • Create an .env file
cat env_template >> .env

.env file content

export PDF_FILE=
export JSON_FILE=
  • Extract text from pdf and save it into JSON
bash show_pdf.sh
  • Resulting JSON format
{
    "file": "/path/to/pdf_file/file.pdf",
    "pages": [
        {
            "page": 0,
            "content": "CONTENT"
        },
        {
            "page": 1,
            "content": "CONTENT"
        }
    ]
}

convert_pdf_to_json's People

Contributors

thomassuedbroecker avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.