2024-04-18 14:43:32 +00:00
|
|
|
import { expect, tap } from '@push.rocks/tapbundle';
|
|
|
|
import * as smartocr from '../ts/index.js';
|
2021-11-28 22:15:14 +00:00
|
|
|
|
2021-11-29 15:29:15 +00:00
|
|
|
let testOcrInstance: smartocr.SmartOcr;
|
|
|
|
|
|
|
|
tap.test('should create a valid instance of Smartocr', async () => {
|
|
|
|
testOcrInstance = await smartocr.SmartOcr.createAndInit();
|
2024-04-18 14:43:32 +00:00
|
|
|
expect(testOcrInstance).toBeInstanceOf(smartocr.SmartOcr);
|
2021-11-29 15:29:15 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('should ocr a pdfBuffer', async () => {
|
2024-04-18 14:43:32 +00:00
|
|
|
const smartfile = await import('@push.rocks/smartfile');
|
|
|
|
const pdfBuffer = (await smartfile.SmartFile.fromFilePath('./test/demo_without_textlayer.pdf'))
|
2021-11-29 15:29:15 +00:00
|
|
|
.contentBuffer;
|
2021-12-01 01:57:57 +00:00
|
|
|
const resultBuffer = await testOcrInstance.processPdfBuffer(pdfBuffer);
|
|
|
|
console.log(resultBuffer);
|
2021-11-28 22:15:14 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
tap.start();
|