Giter VIP home page Giter VIP logo

naivepdf's Introduction

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()

naivepdf's People

Contributors

naivefeeling avatar

Watchers

 avatar

naivepdf's Issues

Fail on color initialization

Traceback (most recent call last):
File "C:/Users/marek/pypdf/pdf/pdf/naivetest.py", line 25, in
main()
File "C:/Users/marek/pypdf/pdf/pdf/naivetest.py", line 12, in main
for i, page in enumerate(doc.pages):
File "C:\Users\marek\pypdf\pdf\venv\lib\site-packages\naivepdf\pdfdocument.py", line 84, in pages
i.interpret()
File "C:\Users\marek\pypdf\pdf\venv\lib\site-packages\naivepdf\pdfpage.py", line 247, in interpret
getattr(self, operator)()
File "C:\Users\marek\pypdf\pdf\venv\lib\site-packages\naivepdf\pdfpage.py", line 352, in cs
self.graphics_states['non_stroking_color'] = self.initial_color(color_space)
File "C:\Users\marek\pypdf\pdf\venv\lib\site-packages\naivepdf\pdfpage.py", line 263, in initial_color
initial_color = [0.0] * color_space['value']
TypeError: can't multiply sequence by non-int of type 'NoneType'
color_space: {'name': b'Lab', 'value': None}

pdf: http://www.mqq.pl/DL.pdf

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.