GithubHelp home page GithubHelp logo

pdf-ocr's Introduction

pdf-ocr

node module that will do OCR on PDFs that do not contain searchable text.

Forked from pdf-extract

[https://www.npmjs.com/package/pdf-extract] by Noah Isaacson.

Differences between pdf-ocr and pdf-extract

  • pdf-extract instructions were outdated when it came to installing dependant binaries. I ran into a couple of pitfalls and wanted to make sure others did not if they used this version.
  • Removed the instructions to update the trained data for tesseract, since version 3.05.01 was newer then the instructions on pdf-extract.
  • Updated code to use ES6 javascript syntax.
  • I Needed an option to OCR just the first page of the PDF.
  • This version currently does not OCR searchable PDFs. Plenty of options out there that does this.
  • If you need to OCR searchable PDFs, I recommend using pdf-extract instead. (However, use the instructions below to get the dependant binaries.)

Installation

npm install pdf-ocr --save

After installing pdf-ocr, the following binaries listed below will need to be on your system, as well as in the paths in your environment settings.

OSX

pdftk

  • Grab the package installer at http://www.pdflabs.com/docs/install-pdftk/

  • If you're installing on OSX Sierra or High Sierra, you'll need to make sure you use the package installer pdftk_server-2.02-mac_osx-10.11-setup.pkg

  • Other versions, seemed to hang the process. If the tests fail, this could the main reason why.

ghostscript

brew install gs

tesseract

brew install tesseract

After tesseract is installed you need to install the alphanumeric config

cd <root of this module>
cp "./share/configs/alphanumeric" "/usr/local/Cellar/tesseract/3.05.01/share/tessdata/configs/alphanumeric"

Ubuntu

pdftk

apt-get install pdftk

pdftotext

apt-get install poppler-utils

ghostscript

apt-get install ghostscript

tesseract

apt-get install tesseract-ocr

For the OCR to work, you need to have the tesseract-ocr binaries available on your path. If you only need to handle ASCII characters, the accuracy of the OCR process can be increased by limiting the tesseract output. To do this copy the alphanumeric file included with this module into the tess-data folder on your system.

cd <root of this module>
cp "./share/configs/alphanumeric" "/usr/share/tesseract-ocr/tessdata/configs/alphanumeric"

Windows

pdftk can be installed using the PDFtk Server installer found here: https://www.pdflabs.com/tools/pdftk-server/

ghostscript for Windows can be found at: http://www.ghostscript.com/download/gsdnld.html

  • Make sure you download the General Public License and the correct version (32/64bit).

  • Install it and go to the installation folder (default: "C:\Program Files\gs\gs9.19") and go into the bin folder.

  • Rename the gswin64c to gs, and add the bin folder to your PATH.

tesseract

pdf-ocr's People

Contributors

nielswh avatar

Watchers

James Cloos avatar Deshayes Yann 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.