1

When I try to use ConvertAPIs PDF to txt with Node.js i get the Response 5002: PDF Damaged. Here is my code:

let convertapi = require('convertapi')('secret');
return convertapi.convert('txt', {
    File: pdfFilePath,
}, 'pdf')

I return the Promise to resolve it elsewhere in my Program. As far as my understanding goes, it is an Internal Server Error. There is nothing wrong with the PDF i put in, when I try to convert it with their Website it works.

Thanks in advance for your answers.

Tomas
  • 17,551
  • 43
  • 152
  • 257

1 Answers1

0

Try this

var convertapi = require('convertapi')('secret');
convertapi.convert('txt', {
    File: '/path/to/my_file.pdf'
}, 'pdf').then(function(result) {
    result.saveFiles('/path/to/dir');
});

Also, you may try to catch and log the full exception

convertapi.convert('txt', { File: './examples/files/test.pdf' })
  .then(function(result) {
    return result.saveFiles(dir);
  })
  .catch(function(e) {
    console.log(e.toString());
  });
Tomas
  • 17,551
  • 43
  • 152
  • 257