Skip to content

EthanJWright/pdfparse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PDF Parse

Parse PDF to JSON that is easily consumable by other applications.

The motivation of this project is to parse a PDF into a JSON schema that maintains the structure and hierarchy of the PDF. This means that text related to a title is grouped together, and this can happen at multiple levels of the JSON.

This tool utilizes style information such as color and font size to create definitions for headers and paragraphs. The inspiration and foundation for this approach was sampled from here

My use case is to translate D&D modules into structured JSON so I can then import them as a directory based journal structure in my game.

Installation

python3 -m pip install -r requirements.txt

Use

Note

I am including the pure version of the source in the README, that simply seeks to convert PDFs to HTML using font weights, etc. You can run that with the command below.

# usage: toHtml.py [-h] -i INPUT
python3 toHtml.py --input=input/test.pdf
# usage: parse.py [-h] -i INPUT [-m MAX] [-r ROOT]
#
# Extract text from PDF
#
# optional arguments:
#   -h, --help            show this help message and exit
#   -i INPUT, --input INPUT
#                         input file
#   -m MAX, --max MAX     max header
#   -r ROOT, --root ROOT  root header


# example
python3 parse.py --input=input/test.pdf --max=8 --root="h1"

About

Convert a PDF into a structured JSON that can be utilized by other tools. Attempts to create a parent/child/note heirarchy allowing grouping of sections.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages