Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ocr-document-classification

Package Overview
Dependencies
Maintainers
0
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ocr-document-classification - npm Package Compare versions

Comparing version 1.2.8 to 1.2.9

71

dist/index.js

@@ -1,49 +0,31 @@

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/functions.ts
import { stringSimilarity } from "string-similarity-js";
import * as Tesseract from "tesseract.js";
// src/convert.mjs
var convert_exports = {};
__export(convert_exports, {
convert: () => convert
});
// src/convert.js
import * as pdfjsLib from "pdfjs-dist";
pdfjsLib.GlobalWorkerOptions.workerSrc = "//mozilla.github.io/pdf.js/build/pdf.worker.js";
async function convert(pdfPath) {
pdfjsLib.GlobalWorkerOptions.workerSrc = "//mozilla.github.io/pdf.js/build/pdf.worker.js";
const doc = await pdfjsLib.getDocument(pdfPath);
const page = await doc.getPage(1);
const viewport = page.getViewport({ scale: 1.5 });
const canvas = document.createElement("canvas");
const context = canvas.getContext("2d");
canvas.height = viewport.height;
canvas.width = viewport.width;
await page.render({ canvasContext: context, viewport }).promise;
const buffer = canvas.toDataURL("image/png");
return buffer;
try {
const doc = await pdfjsLib.getDocument(pdfPath).promise;
const page = await doc.getPage(1);
const viewport = page.getViewport({ scale: 1.5 });
const canvas = document.createElement("canvas");
const context = canvas.getContext("2d");
canvas.height = viewport.height;
canvas.width = viewport.width;
const renderContext = {
canvasContext: context,
viewport
};
await page.render(renderContext).promise;
const buffer = canvas.toDataURL("image/png");
return buffer;
} catch (error) {
console.error("Error processing PDF:", error);
throw error;
}
}
var init_convert = __esm({
"src/convert.mjs"() {
"use strict";
}
});
// src/functions.ts
import { stringSimilarity } from "string-similarity-js";
import * as Tesseract from "tesseract.js";
function findTargetWords(documentText, targetWords, threshold = 0.75) {

@@ -85,6 +67,5 @@ const foundTargetWords = [];

};
const { convert: convert2 } = (init_convert(), __toCommonJS(convert_exports));
if (file.type === "application/pdf") {
const pdfPath = URL.createObjectURL(file);
file = await convert2(pdfPath);
file = await convert(pdfPath);
}

@@ -91,0 +72,0 @@ let progress = 0;

{
"name": "ocr-document-classification",
"version": "1.2.8",
"version": "1.2.9",
"description": "Document classification using tesseract.js and string-similarity-js.",

@@ -29,2 +29,3 @@ "main": "./dist/index.cjs",

"dependencies": {
"pdfjs-dist": "^4.4.168",
"string-similarity-js": "^2.1.4",

@@ -31,0 +32,0 @@ "tesseract.js": "^5.1.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc