Parse image-based PDF documents.
Last updated a year ago by salembeats .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @salembeats/pdf-ocr-fork 
SYNC missed versions from official npm registry.


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


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.



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


brew install gs


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"



apt-get install pdftk


apt-get install poppler-utils


apt-get install ghostscript


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"


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.


Current Tags

  • 0.1.0                                ...           latest (a year ago)

1 Versions

  • 0.1.0                                ...           a year ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (3)
Dependents (0)

Copyright 2014 - 2017 © taobao.org |