Skip to main content

yet another pdf texts and tables extractor

Project description

NaivePDF

yet another pdf texts and tables extractor

This project is inspired by pdfminer, and the pdf parts use, rewrite or redesign a lots of it's codes.

The main purpose of this project is to provide a tool that can naively extract text lines and bordered tables from pdf files, and write them into a html file. In most cases it works well.

On the other hand, it's pdf parts can be an alternative of pdfminer that you can use it to extract texts, lines and shapes more simply.

How to Install

  • Python3.6+ required
pip install naivepdf

Example of Use

very simple to use

# encoding: utf-8

from naivepdf.pdfdocument import PDFDocument
from naivepdf.reconstructor import PageReconstructor
from naivepdf.utils.html import html


def main():
    with open('examples/1206061047.pdf', 'rb') as fp:
        data = []
        doc = PDFDocument(fp)
        for i, page in enumerate(doc.pages):
            # as an alternative of pdfminer, just:
            # data.append(page.data)
            reconstructor = PageReconstructor(page)
            data.extend(reconstructor.reconstruct())

    # as an alternative of pdfminer, just:
    # return data
    with open('examples/1206061047.html', 'w', encoding='utf-8') as fp:
        html(fp, data)


if __name__ == '__main__':
    main()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

naivepdf-0.3.tar.gz (3.0 MB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page