Coder Social home page Coder Social logo

ocrmypdf-js's Introduction

ocrmypdf-js

A JavaScript library that adds “layers” of text to images in PDFs, making scanned image PDFs searchable using ocrmypdf, which is a Python application and library.

Prerequisites

For everything to work correctly, you need to have it installed on your OS ocrmypdf.

Example

Debian or Ubuntu users can simply use the following:

sudo apt install ocrmypdf

For more information on how to install on different OS, see the installation documents.

Installation

Install ocrmypdf-js with your preferred package manager

  npm i ocrmypdf-js
  // or
  yarn add ocrmypdf-js
  // or
  pnpm add ocrmypdf-js

Usage/Examples

Basic example ref.

import { OcrMyPdf } from "ocrmypdf-js";

(async () => {
  const ocrmypdf = new OcrMyPdf();

  await ocrmypdf.execute({
    inputPath: "path/to/input.pdf",
    outputPath: "path/to/output.pdf",
  });
})();

Parametros do construtor

When creating the constructor, it is possible to pass some parameters such as:

  • args: string[] see about arguments in documentation
  • inputPath: string input pdf path
  • outputPath: string output pdf path

Tip

💡 If the inputPath or outputPath fields are provided, it is not necessary to provide them during execution.

import { resolve } from "path";
import { OcrMyPdf } from "ocrmypdf-js";

(async () => {
  const args = ["-l por"]; // troca o idioma padrão para português
  const inputPath = resolve("path/simple.pdf");
  const inputPath = resolve("path/simple-ocr.pdf");

  const ocrmypdf = new OcrMyPdf({ args, inputPath, outputPath });

  await ocrmypdf.execute();
})();

Note

The -l por args to work requires the additional selected language to be installed, see how install;

ocrmypdf-js's People

Contributors

piazin avatar

Stargazers

Felix avatar

Watchers

 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.