pdf2json icon indicating copy to clipboard operation
pdf2json copied to clipboard

Unexpected error "stream must have data"

Open dsdjolence opened this issue 7 years ago • 4 comments

From time to time I got this error message An error occurred while parsing the PDF: stream must have data. Some time I pass all pdfs without error and some time with error. I have 2000 pdfs stored on disk, with loop fetch one by one and I want extract text.

async function parsePdf(file: any): Promise<any> {
  return new Promise((resolve, reject) => {
    const pdfParser = new PDFParser(this, 1);
    pdfParser.loadPDF(file.path);

    pdfParser.on("pdfParser_dataError", errData => {
      console.error(errData);
      reject(errData.parserError)
    });
    pdfParser.on("pdfParser_dataReady", pdfData => resolve(pdfParser.getRawTextContent()));
  });
}

Is someone can help me with this issue. Where I'm wrong. Thank you.

EDIT: If I use call directly with buffer, everything work as expected.

dsdjolence avatar Jan 14 '17 23:01 dsdjolence