ocrmypdf-js
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

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;

Readme

Keywords

Package Sidebar

Install

npm i ocrmypdf-js

Weekly Downloads

21

Version

1.1.1

License

ISC

Unpacked Size

26.8 kB

Total Files

8

Last publish

Collaborators

  • lucas_fsouza