I'm trying to get the output of pdftk command with execSync.
Here is the code:
const { execSync } = require('child_process');
const result = execSync(`pdftk ${fileName} dump_data_fields`);
After execution result contains an empty Buffer.
At the same time if I set the output option to inherit {stdio: 'inherit'} the output of the command will be printed to console, so the command works fine.
Here is a full code of such case:
const { execSync } = require('child_process');
execSync(`pdftk ${fileName} dump_data_fields`,{stdio: 'inherit'});
Also simple commands like echo Hello world works fine and it's output stored in result.
What I'm doing wrong with the pdftk command?