ocr-document-classification
Advanced tools
Comparing version 1.2.7 to 1.2.8
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30691
3
316
- Removedmupdf@^0.2.3
- Removedmupdf@0.2.3(transitive)