Git Product home page Git Product logo

lakshay1296 / ocrmypdf_windows Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 4.0 142.92 MB

ocrmyPDF_Windows is inspired by jbarlow83's ocormtpdf. https://github.com/jbarlow83/OCRmyPDF.

Python 63.62% JavaScript 0.02% PostScript 4.52% HTML 24.06% TeX 0.19% C 3.73% CSS 0.06% Emacs Lisp 0.04% Makefile 0.01% Awk 0.01% Shell 0.06% Batchfile 0.04% Perl 0.10% C++ 3.12% PowerShell 0.01% VBScript 0.01% Objective-C 0.11% XSLT 0.29% Fortran 0.02% Smarty 0.01%
ocrmypdf python python3 ocr ocr-recognition ocr-python tesseract tesseract-ocr flask windows

ocrmypdf_windows's Introduction

ocrmyPDF_Windows

I had some issues while using ocrmypdf on windows, it didn't worked at all. So, I just tried to resolve the issues by myself. Made some changes in the ocrmypdf and pikepdf's code. At last I was successful in making it work. I thought by sharing this repo might help someone, so cheers!

Requirements

  • Tesseract v4 (provided in repo) (leptonica is installed by default)
  • qpdf (provided)
  • ghostscript (provided)
  • jbig2enc (provided)
  • Imagemagick (provided)
  • python 3.6 or above
  • ocrmypdf (library)

Steps for installation

You can try to use the ocr_env (virtual env) provided by me. It already has the changes done to the code by me. If it works kindly tell me on my e-mail [email protected].

  • Install tesseract (need to add in environment variables)
  • You don't need to install qpdf, ghostscript, jbig2enc, imagemagick, however you need to mention their path in environment variables.
  • QPDF: your_path\ocrmyPDF_Windows\qpdf-9.1.0\bin
  • ghostscript: your_path\ocrmyPDF_Windows\gs\gs9.27\bin
  • jbig2enc: your_path\ocrmyPDF_Windows\agl-jbig2enc-0.27-14-gc709efe-leptonlib-1.66-win32-bin
  • imagemagick: your_path\ocrmyPDF_Windows\ImageMagick-7.0.8-Q16
  • python 3.6 or above (I'm using 3.8.1)
  • pip install ocrmypdf
  • pip install pikepdf==1.7.0 (newer versions doesn't seem to work)

PikePDF Problem

v1.8.3

The latest version is throwing problem in importing some module. I don't know what exactly. When I navigate the error, it's showing that there's a problem in importing _qpdf. Due to this code does not produce any output.

v1.7.0

By installing this version we can get rid of the v1.8.3 import error. However, it is also not perfect. When we run the code we get AttributeError: 'pikepdf._qpdf.Pdf' object has no attribute 'check' error. To solve that add following code in _methods.py present in "your location\ocrmyPDF_Windows\ocr_env\Lib\site-packages\pikepdf".

Add this after def encryption() method.

def check(self):
        """
        Check if PDF is well-formed.  Similar to ``qpdf --check``.
        Returns:
            list of strings describing errors of warnings in the PDF
        """

        class DiscardingParser(StreamParser):
            def __init__(self):  # pylint: disable=useless-super-delegation
                super().__init__()  # required for C++

            def handle_object(self, obj):
                pass

            def handle_eof(self):
                pass

        problems = []

        try:
            self._decode_all_streams_and_discard()
        except PdfError as e:
            problems.append(str(e))

        discarding_parser = DiscardingParser()

        for basic_page in self.pages:
            page = Page(basic_page)
            try:
                page.parse_contents(discarding_parser)
            except PdfError as e:
                problems.append(str(e))

        for warning in self.get_warnings():
            problems.append("WARNING: " + warning)

        return problems

This solves the previously mentioned error. This does produce output but also gives one more error

For now, I can live with "streamparser" error, however, I'm still trying to figure this error out.

Licensing

You can use this repository in anyway you need. Kindly make any changes in a different branch.

ocrmypdf_windows's People

Contributors

lakshay1296 avatar

Stargazers

 avatar

Watchers

 avatar  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.