ocr-document-classification
Advanced tools
Comparing version 1.3.3 to 1.3.4
@@ -5,3 +5,3 @@ // src/functions.ts | ||
// src/convert.js | ||
// src/convert.ts | ||
import * as pdfjsLib from "pdfjs-dist"; | ||
@@ -15,3 +15,2 @@ pdfjsLib.GlobalWorkerOptions.workerSrc = "https://cdn.jsdelivr.net/npm/pdfjs-dist@4.4.168/build/pdf.worker.min.mjs"; | ||
let blobArray = []; | ||
console.log(`PDF loaded with ${numPages} pages`); | ||
for (let i = 1; i <= totalPages; i++) { | ||
@@ -33,10 +32,14 @@ const page = await doc.getPage(i); | ||
const blob = await new Promise((resolve, reject) => { | ||
canvas.toBlob((blob2) => { | ||
if (blob2) { | ||
console.log("Converted PDF to Blob!"); | ||
resolve(blob2); | ||
} else { | ||
reject(new Error("Failed to convert canvas to blob")); | ||
} | ||
}, "image/png"); | ||
canvas.toBlob( | ||
(blob2) => { | ||
if (blob2) { | ||
console.log("Converted PDF to Blob!"); | ||
resolve(blob2); | ||
} else { | ||
reject(new Error("Failed to convert canvas to blob")); | ||
} | ||
}, | ||
"image/png", | ||
1 | ||
); | ||
}); | ||
@@ -47,3 +50,4 @@ blobArray.push(blob); | ||
} catch (error) { | ||
console.error("Failed to load PDF:", error); | ||
console.error("Failed to load or process PDF:", error); | ||
throw error; | ||
} | ||
@@ -50,0 +54,0 @@ } |
{ | ||
"name": "ocr-document-classification", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "Document classification using tesseract.js and string-similarity-js.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.cjs", |
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
38117
381