Getting errors while using fresh-tabula-js with nestJs.
Express server
import Tabula from "fresh-tabula-js";
const table = new Tabula("t5.pdf", { spreadsheet: true });
console.log(table.extractCsv().output);
NestJS
1) code-1
import { Injectable } from '@nestjs/common';
import Tabula = require('fresh-tabula-js');
@Injectable()
export class PdfExtractorService {
tabula: Tabula;
constructor() {
this.tabula = new Tabula('t5.pdf', { spreadsheet: true });
}
extractPdfToJson() {
const data: Promise<{ output: string; error: string }> =
this.tabula.getData();
console.log(data);
}
}
Error: this.tabula.getData is not a function
2) code-2
import { Injectable } from '@nestjs/common';
import Tabula = require('fresh-tabula-js');
@Injectable()
export class PdfExtractorService {
tabula: Tabula;
constructor() {
this.tabula = new Tabula('t5.pdf', { spreadsheet: true });
}
extractPdfToJson() {
const data: Promise<{ output: string; error: string }> =
this.tabula.extractCsv().output;
console.log(data);
}
}
Error: error TS2339: Property 'extractCsv' does not exist on type 'Tabula'. this.tabula.extractCsv().output;
Tried all possible ways but it is not working with nestJs however it is working with expressJs. How to make it run in nestJS?