优化后端
This commit is contained in:
Generated
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { createWorker } = require('../..');
|
||||
|
||||
const [,, imagePath] = process.argv;
|
||||
const image = path.resolve(__dirname, (imagePath || '../../tests/assets/images/cosmic.png'));
|
||||
|
||||
console.log(`Recognizing ${image}`);
|
||||
|
||||
(async () => {
|
||||
const worker = await createWorker();
|
||||
const { data: { text, pdf } } = await worker.recognize(image, { pdfTitle: 'Example PDF' }, { pdf: true });
|
||||
console.log(text);
|
||||
fs.writeFileSync('tesseract-ocr-result.pdf', Buffer.from(pdf));
|
||||
console.log('Generate PDF: tesseract-ocr-result.pdf');
|
||||
await worker.terminate();
|
||||
})();
|
||||
Reference in New Issue
Block a user