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.7 to 1.2.8

18

dist/index.js

@@ -27,10 +27,14 @@ var __defProp = Object.defineProperty;

});
import * as mupdf from "mupdf";
async function convert(pdfPath) {
const document = new mupdf.Document.openDocument(pdfPath, "application/pdf");
const page = document.loadPage(0);
const pixmap = page.toPixmap(mupdf.Matrix.identity, mupdf.ColorSpace.DeviceRGB, true, true);
const buffer = pixmap.asPNG();
const arr = buffer.asUint8Array();
return new Blob([arr], { type: "image/png" });
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;
}

@@ -37,0 +41,0 @@ var init_convert = __esm({

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

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

"dependencies": {
"mupdf": "^0.2.3",
"string-similarity-js": "^2.1.4",

@@ -32,0 +31,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