npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pdf-ocr

v0.1.0

Published

node module that can ocr pdfs that are not searchable

Downloads

189

Readme

pdf-ocr

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

Inspired from pdf-extract

[https://www.npmjs.com/package/pdf-extract] by Noah Isaacson. Many of the ideas initial design are from this project.

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