Socket
Socket
Sign inDemoInstall

tesseract.js

Package Overview
Dependencies
Maintainers
3
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tesseract.js - npm Package Compare versions

Comparing version 2.0.0-alpha.6 to 2.0.0-alpha.7

.nyc_output/07bcbaa8-f4a6-4135-baf3-fd60ab84b85f.json

30

docs/examples.md

@@ -112,4 +112,6 @@ # Tesseract.js Examples

### with pdf output (^2.0.0-alpha.5)
### with pdf output (^2.0.0-alpha.7)
In this example, pdf file will be downloaded in browser and write to file system in Node.js
```javascript

@@ -136,1 +138,27 @@ import Tesseract from 'tesseract.js';

```
If you want to handle pdf file by yourself
```javascript
import Tesseract from 'tesseract.js';
const { TesseractWorker } = Tesseract;
const worker = new TesseractWorker();
worker
.recognize(
'http://jeroen.github.io/images/testocr.png',
'eng',
{
'tessedit_create_pdf': '1',
'pdf_auto_download': false, // disable auto download
'pdf_bin': true, // add pdf file bin array in result
}
)
.progress((p) => {
console.log('progress', p);
})
.then((result) => {
console.log(result.files.pdf); // You can access pdf binary array here.
});
```

2

docs/local-installation.md

@@ -13,3 +13,3 @@ ## Local Installation

const worker = Tesseract.TesseractWorker({
workerPath: 'https://unpkg.com/tesseract.js@v2.0.0-alpha.6/dist/worker.min.js',
workerPath: 'https://unpkg.com/tesseract.js@v2.0.0-alpha.7/dist/worker.min.js',
langPath: 'https://tessdata.projectnaptha.com/4.0.0',

@@ -16,0 +16,0 @@ corePath: 'https://unpkg.com/tesseract.js-core@v2.0.0-beta.10/tesseract-core.wasm.js',

{
"name": "tesseract.js",
"version": "2.0.0-alpha.6",
"version": "2.0.0-alpha.7",
"description": "Pure Javascript Multilingual OCR",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -42,3 +42,3 @@ # [Tesseract.js](http://tesseract.projectnaptha.com/)

```html
<script src='https://unpkg.com/tesseract.js@v2.0.0-alpha.6/dist/tesseract.min.js'></script>
<script src='https://unpkg.com/tesseract.js@v2.0.0-alpha.7/dist/tesseract.min.js'></script>
```

@@ -45,0 +45,0 @@

@@ -133,3 +133,4 @@ /**

} else if (data.jobId.startsWith('Download')) {
const { path, blob } = data;
const { path, data: d, type } = data;
const blob = new Blob([d], { type });
downloadFile(path, blob);

@@ -136,0 +137,0 @@ }

@@ -47,9 +47,9 @@ /**

writeFile: (path, data, type) => {
const blob = new Blob([data], { type });
self.postMessage({
jobId: 'Download',
path,
blob,
data,
type,
});
},
});

@@ -23,3 +23,5 @@ const { OEM, PSM } = require('./types');

pdf_title: 'Tesseract.js OCR Result',
pdf_auto_download: true,
pdf_bin: false,
},
};

@@ -88,2 +88,3 @@ /**

const handleOutput = (customParams) => {
let files = {};
const {

@@ -94,2 +95,4 @@ tessedit_create_pdf,

pdf_title,
pdf_auto_download,
pdf_bin,
} = {

@@ -105,5 +108,16 @@ ...defaultParams,

pdfRenderer.EndDocument();
adapter.writeFile(`${pdf_name}.pdf`, TessModule.FS.readFile(`/${pdf_name}.pdf`), 'application/pdf');
TessModule._free(pdfRenderer);
const data = TessModule.FS.readFile(`/${pdf_name}.pdf`);
if (pdf_bin) {
files = { pdf: data, ...files };
}
if (pdf_auto_download) {
adapter.writeFile(`${pdf_name}.pdf`, data, 'application/pdf');
}
}
return files;
}

@@ -193,7 +207,7 @@

api.Recognize(null);
handleOutput(params);
const files = handleOutput(params);
const result = dump(TessModule, api);
api.End();
TessModule._free(ptr);
res.resolve(result);
res.resolve({ files, ...result });
})

@@ -200,0 +214,0 @@ ))

@@ -39,6 +39,6 @@ /**

const fs = require('fs');
fs.writeFile(path, data, () => {
console.log('File Write Succeeded!');
fs.writeFile(path, data, (err) => {
if (err) throw err;
});
},
});

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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