node.jspdftk

geting Error on pdffiller : spawn pdftk ENOENT


I use pdffiller on my project

npm install pdffiller

and this is my code

return new Promise((resolve, reject) => {
          pdfFiller.fillFormWithFlatten(sourcePDF,distPath,formValues,false,function (err) {
              if (err) {
                return reject(err);
              }
              return resolve({
                url: distPath
              });
            }
          );
        });

and my pdf is editable and has checkboxes, input boxes and etc.

that pdf saved on sourcePDF directory

pdf filled with formValues object

every time I try to fill the pdf got this error

Error: spawn pdftk ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn pdftk',
  path: 'pdftk',
  spawnargs: [
    'public/uploads/test/0.pdf',
    'fill_form',
    'temp_data1601654837427pd8bn.fdf',
    'output',
    'public/uploads/providers/4939/test/9e6020c5-2369-45fd-b75b-250d7edb3ec5-populate.pdf'
  ],
  cmd: 'pdftk public/uploads/test/0.pdf fill_form temp_data1601654837427pd8bn.fdf output public/uploads/providers/4939/test/9e6020c5-2369-45fd-b75b-250d7edb3ec5-populate.pdf'
}

Solution

  • Thanks to AKX

    it can be installed on snap

    sudo snap install pdftk

    and my problem is fixed